Repository: thundernest/k-9
Issue: tel URI links are stripped by HtmlSanitizer

Please search to check for an existing issue (including closed issues, for which the fix may not have yet been released) before opening a new issue: https://github.com/k9mail/k-9/issues?q=is%3Aissue

### Expected behavior
Tell us what should happen
Click to call link does not work since a few weeks. A click to call link is a hyperlink which is opened by a dialer-application. For Exampel: `<a href="tel:004955555">55555</a>`

### Actual behavior
Tell us what happens instead
Link is shown as plain text

### Steps to reproduce
1. Create a new mail with html code` <a href="tel:004955555">55555</a>` in it
2. Check for new mails in an old version of k9, or in thunderbird and look for the link
3. Check with current k9 mail, link is shown as plain-text.

### Environment
K-9 Mail version: current 5.403

Android version:
7.0 (motorola) and 7.1.2 (lineage) verified

Account type (IMAP, POP3, WebDAV/Exchange):
does not matter
  

Changed files:
k9mail/src/main/java/com/fsck/k9/message/html/HtmlSanitizer.java, k9mail/src/test/java/com/fsck/k9/message/html/HtmlSanitizerTest.java

diff --git a/k9mail/src/main/java/com/fsck/k9/message/html/HtmlSanitizer.java b/k9mail/src/main/java/com/fsck/k9/message/html/HtmlSanitizer.java
index 63e9eaedb..2b197857a 100644
--- a/k9mail/src/main/java/com/fsck/k9/message/html/HtmlSanitizer.java
+++ b/k9mail/src/main/java/com/fsck/k9/message/html/HtmlSanitizer.java
@@ -25,7 +25,8 @@ public class HtmlSanitizer {
                         "align", "bgcolor", "colspan", "headers", "height", "nowrap", "rowspan", "scope", "valign",
                         "width")
                 .addAttributes(":all", "class", "style", "id")
-                .addProtocols("img", "src", "http", "https", "cid", "data");
+                .addProtocols("img", "src", "http", "https", "cid", "data")
+                .addProtocols("a", "href", "tel", "sip", "bitcoin", "ethereum", "rtsp");
 
         cleaner = new Cleaner(whitelist);
         headCleaner = new HeadCleaner();
diff --git a/k9mail/src/test/java/com/fsck/k9/message/html/HtmlSanitizerTest.java b/k9mail/src/test/java/com/fsck/k9/message/html/HtmlSanitizerTest.java
index 38d8d6e4f..3e9f6bf9c 100644
--- a/k9mail/src/test/java/com/fsck/k9/message/html/HtmlSanitizerTest.java
+++ b/k9mail/src/test/java/com/fsck/k9/message/html/HtmlSanitizerTest.java
@@ -213,4 +213,31 @@ public class HtmlSanitizerTest {
                 "<center><font face=\\"Arial\\" color=\\"red\\" size=\\"12\\">A</font></center>" +
                 "</body></html>", toCompactString(result));
     }
+
+    @Test
+    public void shouldKeepUris() {
+        String html = "<html><body>" +
+                "<a href=\\"http://example.com/index.html\\">HTTP</a>" +
+                "<a href=\\"https://example.com/default.html\\">HTTPS</a>" +
+                "<a href=\\"mailto:user@example.com\\">Mailto</a>" +
+                "<a href=\\"tel:00442079460111\\">Telephone</a>" +
+                "<a href=\\"sip:user@example.com\\">SIP</a>" +
+                "<a href=\\"bitcoin:12A1MyfXbW6RhdRAZEqofac5jCQQjwEPBu\\">Bitcoin</a>" +
+                "<a href=\\"ethereum:0x89205A3A3b2A69De6Dbf7f01ED13B2108B2c43e7\\">Ethereum</a>" +
+                "<a href=\\"rtsp://example.com/media.mp4\\">RTSP</a>" +
+                "</body></html>";
+
+        Document result = htmlSanitizer.sanitize(html);
+
+        assertEquals("<html><head></head><body>" +
+                "<a href=\\"http://example.com/index.html\\">HTTP</a>" +
+                "<a href=\\"https://example.com/default.html\\">HTTPS</a>" +
+                "<a href=\\"mailto:user@example.com\\">Mailto</a>" +
+                "<a href=\\"tel:00442079460111\\">Telephone</a>" +
+                "<a href=\\"sip:user@example.com\\">SIP</a>" +
+                "<a href=\\"bitcoin:12A1MyfXbW6RhdRAZEqofac5jCQQjwEPBu\\">Bitcoin</a>" +
+                "<a href=\\"ethereum:0x89205A3A3b2A69De6Dbf7f01ED13B2108B2c43e7\\">Ethereum</a>" +
+                "<a href=\\"rtsp://example.com/media.mp4\\">RTSP</a>" +
+                "</body></html>", toCompactString(result));
+    }
 }