From b52d7c7cd864e948e7a46346c1b9ed0cfa43cec4 Mon Sep 17 00:00:00 2001 From: cketti Date: Sun, 30 Apr 2017 02:42:07 +0200 Subject: [PATCH] Fix linkify issue with https: and rtsp: URIs --- .../java/com/fsck/k9/message/html/HttpUriParser.java | 4 ++-- .../com/fsck/k9/message/html/HttpUriParserTest.java | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/message/html/HttpUriParser.java b/k9mail/src/main/java/com/fsck/k9/message/html/HttpUriParser.java index 1ba302e74..fc0c0b561 100644 --- a/k9mail/src/main/java/com/fsck/k9/message/html/HttpUriParser.java +++ b/k9mail/src/main/java/com/fsck/k9/message/html/HttpUriParser.java @@ -30,11 +30,11 @@ class HttpUriParser implements UriParser { // Scheme String shortScheme = text.substring(currentPos, Math.min(currentPos + 7, text.length())); String longScheme = text.substring(currentPos, Math.min(currentPos + 8, text.length())); - if (shortScheme.equalsIgnoreCase("https://")) { + if (longScheme.equalsIgnoreCase("https://")) { currentPos += "https://".length(); } else if (shortScheme.equalsIgnoreCase("http://")) { currentPos += "http://".length(); - } else if (longScheme.equalsIgnoreCase("rtsp://")) { + } else if (shortScheme.equalsIgnoreCase("rtsp://")) { currentPos += "rtsp://".length(); } else { return startPos; diff --git a/k9mail/src/test/java/com/fsck/k9/message/html/HttpUriParserTest.java b/k9mail/src/test/java/com/fsck/k9/message/html/HttpUriParserTest.java index 1e9ae8906..6cbf4a6f9 100644 --- a/k9mail/src/test/java/com/fsck/k9/message/html/HttpUriParserTest.java +++ b/k9mail/src/test/java/com/fsck/k9/message/html/HttpUriParserTest.java @@ -27,6 +27,16 @@ public class HttpUriParserTest { assertLinkify("http://www.google.com"); } + @Test + public void simpleDomainWithHttps() { + assertLinkify("https://www.google.com"); + } + + @Test + public void simpleRtspUri() { + assertLinkify("rtsp://example.com/media.mp4"); + } + @Test public void invalidDomainIgnored() { assertLinkIgnored("http://-www.google.com");