Loading k9mail/build.gradle +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ dependencies { compile "com.squareup.okio:okio:${okioVersion}" compile 'commons-io:commons-io:2.4' compile "com.android.support:support-v4:${androidSupportLibraryVersion}" compile 'net.sourceforge.htmlcleaner:htmlcleaner:2.16' compile 'net.sourceforge.htmlcleaner:htmlcleaner:2.18' compile 'de.cketti.library.changelog:ckchangelog:1.2.1' compile 'com.github.bumptech.glide:glide:3.6.1' compile 'com.splitwise:tokenautocomplete:2.0.7' Loading k9mail/src/main/java/com/fsck/k9/helper/HtmlSanitizer.java +1 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ public class HtmlSanitizer { properties.setOmitDoctypeDeclaration(false); properties.setTranslateSpecialEntities(false); properties.setRecognizeUnicodeChars(false); properties.setIgnoreQuestAndExclam(false); return properties; } Loading k9mail/src/test/java/com/fsck/k9/helper/HtmlSanitizerTest.java +34 −0 Original line number Diff line number Diff line Loading @@ -99,4 +99,38 @@ public class HtmlSanitizerTest { assertEquals("<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" /></head>" + "<body>Message</body></html>", htmlSanitizer.sanitize(html)); } @Test public void shouldProduceValidHtmlFromHtmlWithXmlDeclaration() { String html = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<html><head></head><body></body></html>"; String result = htmlSanitizer.sanitize(html); assertEquals("<html><head></head><body></body></html>", result); } @Test public void shouldNormalizeTables() { String html = "<html><head></head><body><table><tr><td></td><td></td></tr></table></body></html>"; String result = htmlSanitizer.sanitize(html); assertEquals("<html><head></head><body><table><tbody>" + "<tr><td></td><td></td></tr>" + "</tbody></table></body></html>", result); } @Test public void shouldHtmlEncodeXmlDirectives() { String html = "<html><head></head><body><table>" + "<tr><td><!==><!==>Hmailserver service shutdown:</td><td><!==><!==>Ok</td></tr>" + "</table></body></html>"; String result = htmlSanitizer.sanitize(html); assertEquals("<html><head></head><body><table><tbody>" + "<tr><td><!==><!==>Hmailserver service shutdown:</td><td><!==><!==>Ok</td></tr>" + "</tbody></table></body></html>", result); } } Loading
k9mail/build.gradle +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ dependencies { compile "com.squareup.okio:okio:${okioVersion}" compile 'commons-io:commons-io:2.4' compile "com.android.support:support-v4:${androidSupportLibraryVersion}" compile 'net.sourceforge.htmlcleaner:htmlcleaner:2.16' compile 'net.sourceforge.htmlcleaner:htmlcleaner:2.18' compile 'de.cketti.library.changelog:ckchangelog:1.2.1' compile 'com.github.bumptech.glide:glide:3.6.1' compile 'com.splitwise:tokenautocomplete:2.0.7' Loading
k9mail/src/main/java/com/fsck/k9/helper/HtmlSanitizer.java +1 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ public class HtmlSanitizer { properties.setOmitDoctypeDeclaration(false); properties.setTranslateSpecialEntities(false); properties.setRecognizeUnicodeChars(false); properties.setIgnoreQuestAndExclam(false); return properties; } Loading
k9mail/src/test/java/com/fsck/k9/helper/HtmlSanitizerTest.java +34 −0 Original line number Diff line number Diff line Loading @@ -99,4 +99,38 @@ public class HtmlSanitizerTest { assertEquals("<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" /></head>" + "<body>Message</body></html>", htmlSanitizer.sanitize(html)); } @Test public void shouldProduceValidHtmlFromHtmlWithXmlDeclaration() { String html = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<html><head></head><body></body></html>"; String result = htmlSanitizer.sanitize(html); assertEquals("<html><head></head><body></body></html>", result); } @Test public void shouldNormalizeTables() { String html = "<html><head></head><body><table><tr><td></td><td></td></tr></table></body></html>"; String result = htmlSanitizer.sanitize(html); assertEquals("<html><head></head><body><table><tbody>" + "<tr><td></td><td></td></tr>" + "</tbody></table></body></html>", result); } @Test public void shouldHtmlEncodeXmlDirectives() { String html = "<html><head></head><body><table>" + "<tr><td><!==><!==>Hmailserver service shutdown:</td><td><!==><!==>Ok</td></tr>" + "</table></body></html>"; String result = htmlSanitizer.sanitize(html); assertEquals("<html><head></head><body><table><tbody>" + "<tr><td><!==><!==>Hmailserver service shutdown:</td><td><!==><!==>Ok</td></tr>" + "</tbody></table></body></html>", result); } }