diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index e1e80b4c8a..cc7f533974 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -60,7 +60,7 @@ import static androidx.core.text.HtmlCompat.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE; public class HtmlHelper { private static final int PREVIEW_SIZE = 250; - private static Pattern pattern = Pattern.compile("([http|https]+://[\\w\\S(\\.|:|/)]+)"); + private static Pattern pattern = Pattern.compile("https?://[\\w#%&()*+,-./:;=?@\\[\\]_|~]+"); private static final List heads = Arrays.asList("h1", "h2", "h3", "h4", "h5", "h6", "p", "table", "ol", "ul", "br", "hr"); private static final List tails = Arrays.asList("h1", "h2", "h3", "h4", "h5", "h6", "p", "ol", "ul", "li"); diff --git a/app/src/test/java/eu/faircode/email/HtmlHelperTest.java b/app/src/test/java/eu/faircode/email/HtmlHelperTest.java index ee1f9d04b6..aeb1fdf1bd 100644 --- a/app/src/test/java/eu/faircode/email/HtmlHelperTest.java +++ b/app/src/test/java/eu/faircode/email/HtmlHelperTest.java @@ -21,8 +21,8 @@ class HtmlHelperTest { testAutolink( "one hhhhh|spt://example.org three", - // FIXME: "hhhhh|spt" is not a proper URL scheme. - "one hhhhh|spt://example.org three" + // This string had been wrongly interpreted as a complete URL up to February 2019. + "one hhhhh|spt://example.org three" ); testAutolink( @@ -37,16 +37,14 @@ class HtmlHelperTest { testAutolink( "Go to \"http://example.org/\".", - // FIXME: The quote must not end up as part of the URL. - "Go to \"http://example.org/\"." + "Go to \"http://example.org/\"." ); testAutolink( "Go to .", // FIXME: The < must be encoded as <. - // FIXME: THe > must not end up as part of the URL. - "Go to <.\">http://example.org/>." + "Go to <http://example.org/>." ); }