|
|
@ -94,6 +94,47 @@ public class HtmlHelperTest {
|
|
|
|
" and " +
|
|
|
|
" and " +
|
|
|
|
"<a href=\"http://example.org/\">http://example.org/</a>"
|
|
|
|
"<a href=\"http://example.org/\">http://example.org/</a>"
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"<a href=\"http://typo3.example.org/?tt_news[uid]=123\">" +
|
|
|
|
|
|
|
|
"http://typo3.example.org/?tt_news[uid]=123</a>"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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 <a href=\"https://en.wikipedia.org/wiki/Java_(programming_language)\">" +
|
|
|
|
|
|
|
|
"https://en.wikipedia.org/wiki/Java_(programming_language)</a>, " +
|
|
|
|
|
|
|
|
"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 <a href=\"https://example.org)\">" +
|
|
|
|
|
|
|
|
"https://example.org)</a>, 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==",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"<a href=\"https://example.org/forgot?token=AAAAAA==\">" +
|
|
|
|
|
|
|
|
"https://example.org/forgot?token=AAAAAA==</a>"
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void testAutolink(String input, String expectedOutput) {
|
|
|
|
private void testAutolink(String input, String expectedOutput) {
|
|
|
|