Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge #7160
Browse files Browse the repository at this point in the history
7160:  Closes #7142: Sanitize url in HttpIconLoader  r=pocmo a=Amejia481



Co-authored-by: Arturo Mejia <arturomejiamarmol@gmail.com>
  • Loading branch information
MozLando and Amejia481 committed Jun 3, 2020
2 parents bec28a5 + 98158c8 commit 3b63242
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private fun JSONObject.toIconResource(): IconRequest.Resource? {
val maskable = optBoolean("maskable", false)

return IconRequest.Resource(
url = url,
url = url.trim(),
type = type,
sizes = sizes,
mimeType = if (mimeType.isNullOrEmpty()) null else mimeType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,21 @@ class IconMessageKtTest {
val restoredResources = json.toIconResources()
assertEquals(resources, restoredResources)
}

@Test
fun `Url must be sanitized`() {
val resources = listOf(
IconRequest.Resource(
url = "\nhttps://www.mozilla.org/icon64.png\n",
sizes = listOf(Size(64, 64)),
mimeType = "image/png",
type = IconRequest.Resource.Type.FAVICON
)
)

val json = resources.toJSON()

val restoredResource = json.toIconResources().first()
assertEquals("https://www.mozilla.org/icon64.png", restoredResource.url)
}
}
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ permalink: /changelog/
* [Gecko](https://github.com/mozilla-mobile/android-components/blob/master/buildSrc/src/main/java/Gecko.kt)
* [Configuration](https://github.com/mozilla-mobile/android-components/blob/master/buildSrc/src/main/java/Config.kt)

* **browser-icons**
* Fixed issue [#7142](https://github.com/mozilla-mobile/android-components/issues/7142)

# 44.0.0

* [Commits](https://github.com/mozilla-mobile/android-components/compare/v43.0.0...v44.0.0)
Expand Down

0 comments on commit 3b63242

Please sign in to comment.