Fix .onion link linkification.

Fixes #11458.
This commit is contained in:
Justin Tracey
2022-04-14 17:58:05 -04:00
committed by Greyson Parrelli
parent 6563ea970f
commit 8a2f89b4f6
8 changed files with 108 additions and 77 deletions

View File

@@ -1,4 +1,4 @@
package org.thoughtcrime.securesms.linkpreview;
package org.thoughtcrime.securesms.util;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -10,7 +10,7 @@ import java.util.Collection;
import static junit.framework.TestCase.assertEquals;
@RunWith(Parameterized.class)
public class LinkPreviewUtilTest_isLegal {
public class LinkUtilTest_isLegal {
private final String input;
private final boolean output;
@@ -24,12 +24,12 @@ public class LinkPreviewUtilTest_isLegal {
{ "https://foo.google.com/some/path.html", true },
{ "кц.рф", true },
{ "https://кц.рф/some/path", true },
{ "https://abcdefg.onion", true },
{ "https://abcdefg.i2p", true },
{ "http://кц.com", false },
{ "кц.com", false },
{ "http://asĸ.com", false },
{ "http://foo.кц.рф", false },
{ "https://abcdefg.onion", false },
{ "https://abcdefg.i2p", false },
{ "кц.рф\u202C", false },
{ "кц.рф\u202D", false },
{ "кц.рф\u202E", false },
@@ -40,13 +40,13 @@ public class LinkPreviewUtilTest_isLegal {
});
}
public LinkPreviewUtilTest_isLegal(String input, boolean output) {
public LinkUtilTest_isLegal(String input, boolean output) {
this.input = input;
this.output = output;
}
@Test
public void isLegal() {
assertEquals(output, LinkPreviewUtil.isLegalUrl(input));
assertEquals(output, LinkUtil.isLegalUrl(input));
}
}