Catch malformed percent escapes when parsing call link urls.

This commit is contained in:
Greyson Parrelli
2026-07-15 16:43:47 -04:00
parent b60f53f4df
commit 66390b4fe4
2 changed files with 38 additions and 0 deletions
@@ -110,6 +110,9 @@ object CallLinks {
} catch (_: UnsupportedEncodingException) {
Log.w(TAG, "Invalid url: $url")
return null
} catch (_: IllegalArgumentException) {
Log.w(TAG, "Invalid url: $url")
return null
}
val key = fragmentQuery[ROOT_KEY]
@@ -0,0 +1,35 @@
/*
* Copyright 2026 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.thoughtcrime.securesms.calls.links
import org.junit.Assert.assertNull
import org.junit.BeforeClass
import org.junit.Test
import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.testutil.EmptyLogger
/**
* See [CallLinks]
*/
class CallLinksTest {
companion object {
@JvmStatic
@BeforeClass
fun setUpClass() {
Log.initialize(EmptyLogger())
}
}
@Test
fun `parseUrl returns null for malformed percent escape instead of throwing`() {
assertNull(CallLinks.parseUrl("https://signal.link/call/#key=abcdef&n=%ZZ"))
}
@Test
fun `parseUrl returns null for malformed percent escape in key instead of throwing`() {
assertNull(CallLinks.parseUrl("https://signal.link/call/#key=%ZZ"))
}
}