diff --git a/app/src/test/java/eu/faircode/email/HtmlHelperTest.java b/app/src/test/java/eu/faircode/email/HtmlHelperTest.java index 613afc2e44..9e452a6006 100644 --- a/app/src/test/java/eu/faircode/email/HtmlHelperTest.java +++ b/app/src/test/java/eu/faircode/email/HtmlHelperTest.java @@ -94,6 +94,47 @@ public class HtmlHelperTest { " and " + "http://example.org/" ); + + // Square brackets in URLs are typically generated by Typo3. + // See https://forge.typo3.org/issues/22118. + testAutolink( + "http://typo3.example.org/?tt_news[uid]=123", + + "" + + "http://typo3.example.org/?tt_news[uid]=123" + ); + + // When copying a Wikipedia URL in Google Chrome, the parentheses are not + // percent-encoded. This creates an ambiguity since the closing parenthesis + // typically appears at the very end of the URL, where it could equally well + // belong to the surrounding human-language text. + testAutolink( + "See https://en.wikipedia.org/wiki/Java_(programming_language), " + + "which explains it all.", + + "See " + + "https://en.wikipedia.org/wiki/Java_(programming_language), " + + "which explains it all." + ); + + testAutolink( + "See my homepage (at https://example.org), with lots of examples.", + + // FIXME: The URL doesn't contain an opening parenthesis, therefore + // the closing parenthesis probably also doesn't belong to it. + "See my homepage (at " + + "https://example.org), with lots of examples." + ); + + // The terminating sequence of a base64-encoded URL parameter is always + // part of the URL. This is typically used for password reset links, and + // these are often sent via e-mail. + testAutolink( + "https://example.org/forgot?token=AAAAAA==", + + "" + + "https://example.org/forgot?token=AAAAAA==" + ); } private void testAutolink(String input, String expectedOutput) {