Fix ComposerPageState::containsAttachmentKeyword

Just use ComposerPageState::htmlToText to get the email's main content
without quotes, not some custom code.
This commit is contained in:
Michael Gratton 2019-10-07 23:49:12 +11:00
parent a8ef91f3a8
commit 69e3cdf9b5
2 changed files with 7 additions and 24 deletions

View file

@ -20,11 +20,12 @@ class ComposerPageStateTest : ClientWebViewTestCase<ComposerWebView> {
add_test("edit_context_font", edit_context_font);
add_test("edit_context_link", edit_context_link);
add_test("indent_line", indent_line);
add_test("contains_attachment_keywords", contains_attachment_keywords);
add_test("clean_content", clean_content);
add_test("get_html", get_html);
add_test("get_text", get_text);
add_test("contains_keywords", contains_keywords);
// Depends contains_keywords and html_to_text_with_blacklist
add_test("contains_attachment_keywords", contains_attachment_keywords);
add_test("replace_non_breaking_space", replace_non_breaking_space);
try {

View file

@ -239,30 +239,12 @@ ComposerPageState.prototype = {
return true;
}
// Check interesting body text
let node = this.bodyPart.firstChild;
let content = [];
let breakingElements = new Set([
"BR", "P", "DIV", "BLOCKQUOTE", "TABLE", "OL", "UL", "HR"
]);
while (node != null) {
if (node.nodeType == Node.TEXT_NODE) {
content.push(node.textContent);
} else if (content.nodeType == Node.ELEMENT_NODE) {
let isBreaking = breakingElements.has(node.nodeName);
if (isBreaking) {
content.push("\n");
}
// Only include non-quoted text
if (content.nodeName != "BLOCKQUOTE") {
content.push(content.textContent);
}
}
node = node.nextSibling;
}
// Check the body text
let content = ComposerPageState.htmlToText(
this.bodyPart, ["blockquote"]
);
return ComposerPageState.containsKeywords(
content.join(""), completeKeys, suffixKeys
content, completeKeys, suffixKeys
);
},
tabOut: function() {