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());
+ }
}