From 98974a76997c0ead1243cc737380c327d59c649a Mon Sep 17 00:00:00 2001 From: cketti Date: Fri, 17 Mar 2017 15:19:16 +0100 Subject: [PATCH] Fix bug with advancing the position when linkifying failed --- .../main/java/com/fsck/k9/message/html/UriLinkifier.java | 2 +- .../java/com/fsck/k9/message/html/UriLinkifierTest.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/k9mail/src/main/java/com/fsck/k9/message/html/UriLinkifier.java b/k9mail/src/main/java/com/fsck/k9/message/html/UriLinkifier.java index 0fd97ac1c..49e86e7cc 100644 --- a/k9mail/src/main/java/com/fsck/k9/message/html/UriLinkifier.java +++ b/k9mail/src/main/java/com/fsck/k9/message/html/UriLinkifier.java @@ -51,7 +51,7 @@ public class UriLinkifier { boolean uriWasNotLinkified = newPos <= startPos; if (uriWasNotLinkified) { outputBuffer.append(text.charAt(startPos)); - currentPos++; + currentPos = startPos + 1; } else { currentPos = (newPos > currentPos) ? newPos : currentPos + 1; } diff --git a/k9mail/src/test/java/com/fsck/k9/message/html/UriLinkifierTest.java b/k9mail/src/test/java/com/fsck/k9/message/html/UriLinkifierTest.java index 4d81baad5..1e86b45e9 100644 --- a/k9mail/src/test/java/com/fsck/k9/message/html/UriLinkifierTest.java +++ b/k9mail/src/test/java/com/fsck/k9/message/html/UriLinkifierTest.java @@ -115,4 +115,13 @@ public class UriLinkifierTest { assertEquals("myhttp: http://example.org", outputBuffer.toString()); } + + @Test + public void schemaMatchWithInvalidUriInMiddleOfTextFollowedVyValidUri() throws Exception { + String text = "prefix http:42 http://example.org"; + + UriLinkifier.linkifyText(text, outputBuffer); + + assertEquals("prefix http:42 http://example.org", outputBuffer.toString()); + } }