[geary/mjog/589-attachment-keyword-check: 3/3] Fix ComposerPageState::containsAttachmentKeyword
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/589-attachment-keyword-check: 3/3] Fix ComposerPageState::containsAttachmentKeyword
- Date: Mon, 7 Oct 2019 12:56:49 +0000 (UTC)
commit 69e3cdf9b57732cee112720938589721eede6d4e
Author: Michael Gratton <mike vee net>
Date: Mon Oct 7 23:49:12 2019 +1100
Fix ComposerPageState::containsAttachmentKeyword
Just use ComposerPageState::htmlToText to get the email's main content
without quotes, not some custom code.
test/js/composer-page-state-test.vala | 3 ++-
ui/composer-web-view.js | 28 +++++-----------------------
2 files changed, 7 insertions(+), 24 deletions(-)
---
diff --git a/test/js/composer-page-state-test.vala b/test/js/composer-page-state-test.vala
index 038c99fa..6a7781b2 100644
--- a/test/js/composer-page-state-test.vala
+++ b/test/js/composer-page-state-test.vala
@@ -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 {
diff --git a/ui/composer-web-view.js b/ui/composer-web-view.js
index 564e5c5a..3abda414 100644
--- a/ui/composer-web-view.js
+++ b/ui/composer-web-view.js
@@ -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() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]