mirror of https://github.com/M66B/FairEmail.git
Check for HTML tag in plain text messages
This commit is contained in:
parent
6579f6ec40
commit
9adc158ace
|
@ -129,6 +129,10 @@ public class MessageHelper {
|
|||
private static final int MAX_META_EXCERPT = 1024; // characters
|
||||
private static final int FORMAT_FLOWED_LINE_LENGTH = 72;
|
||||
|
||||
private static final String DOCTYPE = "<!DOCTYPE";
|
||||
private static final String HTML_START = "<html>";
|
||||
private static final String HTML_END = "</html>";
|
||||
|
||||
private static final List<Charset> CHARSET16 = Collections.unmodifiableList(Arrays.asList(
|
||||
StandardCharsets.UTF_16,
|
||||
StandardCharsets.UTF_16BE,
|
||||
|
@ -1990,7 +1994,6 @@ public class MessageHelper {
|
|||
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)) {
|
||||
|
@ -2001,6 +2004,17 @@ public class MessageHelper {
|
|||
}
|
||||
}
|
||||
|
||||
int s = 0;
|
||||
while (s < result.length() && Character.isWhitespace(result.charAt(s)))
|
||||
s++;
|
||||
int e = result.length();
|
||||
while (e > 0 && Character.isWhitespace(result.charAt(e - 1)))
|
||||
e--;
|
||||
if (s + HTML_START.length() < result.length() && e - HTML_END.length() >= 0 &&
|
||||
result.substring(s, s + HTML_START.length()).equalsIgnoreCase(HTML_START) &&
|
||||
result.substring(e - HTML_END.length(), e).equalsIgnoreCase(HTML_END))
|
||||
return result;
|
||||
|
||||
result = "<div x-plain=\"true\">" + HtmlHelper.formatPre(result) + "</div>";
|
||||
} else if (h.isHtml()) {
|
||||
// Conditionally upgrade to UTF8
|
||||
|
|
Loading…
Reference in New Issue