mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-25 11:20:47 +01:00
Refine link preview domain restrictions.
This commit is contained in:
@@ -36,7 +36,16 @@ public class LinkUtilTest_isLegal {
|
||||
{ "кц.рф\u2500", false },
|
||||
{ "кц.рф\u25AA", false },
|
||||
{ "кц.рф\u25FF", false },
|
||||
{ "", false }
|
||||
{ "", false },
|
||||
{ "cool.example", true },
|
||||
{ "cool.example.com", true },
|
||||
{ "cool.example.net", true },
|
||||
{ "cool.example.org", true },
|
||||
{ "cool.invalid", true },
|
||||
{ "cool.localhost", true },
|
||||
{ "localhost", true },
|
||||
{ "https://localhost", true },
|
||||
{ "cool.test", true }
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.thoughtcrime.securesms.util
|
||||
|
||||
import junit.framework.TestCase
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.Parameterized
|
||||
|
||||
@RunWith(Parameterized::class)
|
||||
class LinkUtilTest_isValidPreviewUrl(private val input: String, private val output: Boolean) {
|
||||
|
||||
@Test
|
||||
fun isLegal() {
|
||||
TestCase.assertEquals(output, LinkUtil.isValidPreviewUrl(input))
|
||||
}
|
||||
|
||||
companion object {
|
||||
@Parameterized.Parameters
|
||||
@JvmStatic
|
||||
fun data(): Collection<Array<Any>> {
|
||||
return listOf(
|
||||
arrayOf("google.com", false),
|
||||
arrayOf("foo.google.com", false),
|
||||
arrayOf("https://foo.google.com", true),
|
||||
arrayOf("https://foo.google.com.", true),
|
||||
arrayOf("https://foo.google.com/some/path.html", true),
|
||||
arrayOf("кц.рф", false),
|
||||
arrayOf("https://кц.рф/some/path", true),
|
||||
arrayOf("https://abcdefg.onion", false),
|
||||
arrayOf("https://abcdefg.i2p", false),
|
||||
arrayOf("http://кц.com", false),
|
||||
arrayOf("кц.com", false),
|
||||
arrayOf("http://asĸ.com", false),
|
||||
arrayOf("http://foo.кц.рф", false),
|
||||
arrayOf("кц.рф\u202C", false),
|
||||
arrayOf("кц.рф\u202D", false),
|
||||
arrayOf("кц.рф\u202E", false),
|
||||
arrayOf("кц.рф\u2500", false),
|
||||
arrayOf("кц.рф\u25AA", false),
|
||||
arrayOf("кц.рф\u25FF", false),
|
||||
arrayOf("", false),
|
||||
arrayOf("https://cool.example", false),
|
||||
arrayOf("https://cool.example.com", false),
|
||||
arrayOf("https://cool.example.net", false),
|
||||
arrayOf("https://cool.example.org", false),
|
||||
arrayOf("https://cool.invalid", false),
|
||||
arrayOf("https://cool.localhost", false),
|
||||
arrayOf("https://localhost", false),
|
||||
arrayOf("https://cool.test", false),
|
||||
arrayOf("https://cool.invalid.com", true),
|
||||
arrayOf("https://cool.localhost.signal.org", true),
|
||||
arrayOf("https://cool.test.blarg.gov", true)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user