mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-30 05:44:51 +02:00
Quick check for HTML in plain text
This commit is contained in:
@@ -1956,6 +1956,19 @@ public class MessageHelper {
|
||||
|
||||
if ("flowed".equalsIgnoreCase(h.contentType.getParameter("format")))
|
||||
result = HtmlHelper.flow(result);
|
||||
|
||||
// https://www.w3.org/QA/2002/04/valid-dtd-list.html
|
||||
final String DOCTYPE = "<!DOCTYPE";
|
||||
if (result.length() > DOCTYPE.length()) {
|
||||
String doctype = result.substring(0, DOCTYPE.length()).toUpperCase(Locale.ROOT);
|
||||
if (doctype.startsWith(DOCTYPE)) {
|
||||
String[] words = result.split("\\s+");
|
||||
if (words.length > 1 &&
|
||||
"HTML".equals(words[1].toUpperCase(Locale.ROOT)))
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
result = "<div x-plain=\"true\">" + HtmlHelper.formatPre(result) + "</div>";
|
||||
} else if (h.isHtml()) {
|
||||
// Conditionally upgrade to UTF8
|
||||
|
||||
Reference in New Issue
Block a user