-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strip gmail's html quote properly #49
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,14 +77,29 @@ function processHtmlBlockquotes(nodes, replyHeaderHandling, maxDepth, depth) { | |
for (let node of nodes) { | ||
if (node.nodeType === Node.ELEMENT_NODE && | ||
node.nodeName === "BLOCKQUOTE" && | ||
node.hasAttribute("type") && node.getAttribute("type") === "cite") { | ||
(node.hasAttribute("type") && node.getAttribute("type") === "cite" || // regular quote | ||
node.hasAttribute("class") && node.getAttribute("class") === "gmail_quote")) // gmail web interface quote | ||
{ | ||
if (depth > maxDepth) { | ||
node.remove(); | ||
} else { | ||
processHtmlBlockquotes(node.childNodes, replyHeaderHandling, maxDepth, depth + 1); | ||
} | ||
} | ||
|
||
else if (node.nodeType === Node.ELEMENT_NODE && | ||
node.nodeName === "DIV" && | ||
node.hasAttribute("class") && node.getAttribute("class") === "gmail_quote") // gmail web interface pre-quote div | ||
{ | ||
processHtmlBlockquotes(node.childNodes, replyHeaderHandling, maxDepth, depth); | ||
} | ||
|
||
else if (node.nodeType === Node.ELEMENT_NODE && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm... yet another variant. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your email server rejects .eml files. |
||
node.nodeName === "DIV") // generic div | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ValdikSS : I'm not sure that this last else-if is a bit too generic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check my email example, it won't work correctly without this code. If you can make it better, go ahead. |
||
{ | ||
processHtmlBlockquotes(node.childNodes, replyHeaderHandling, maxDepth, depth); | ||
} | ||
|
||
if (replyHeaderHandling.remove && depth > maxDepth) { | ||
if (replyHeaderSearchRegExp.test(node.innerHTML)) { | ||
node.innerHTML = node.innerHTML.replaceAll(new RegExp(replyHeaderPattern + "<br>", "g"), ""); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that the "gmail variant" has a "BLOCKQUOTE" or "DIV" as the node name???
If gmail only uses DIV... then why do we need the altered if condition above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is possible when you already have a long conversation with multiple quotations from different clients (gmail web/regular different email clients).
This patch actually adds gmail web quote handling and fixes support of other clients' quotes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've simplified the whole section and pushed it to the dev-branch.
Please let me know if this still works for you.
Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new version doesn't work for this exact email with maximum quote depth allowed > 1.
Try it yourself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit a16a219 doesn't work correctly on this email (with maximum quote depth allowed = 3 it strips down to 1 quotation), and ce5808b does not work at all with quote depth allowed > 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ValdikSS I'm sorry... but I hope you understand that I'm going to let this issue rest for a while.
I really tried to reproduce the issue... but couldn't.
Your modifications to the code would introduce complexity and also may lead to unwanted side-effects (since at some point you treat simple DIVs as quotes, etc.).
Hope you understand that I'm a bit hesitant here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's because you're using "reply" button while in a plain text view. It does add color bars, just like on your screenshot (no non-colored bars). In this mode the extension works correctly. However, it doesn't while replying in HTML mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. Okay... just watched it.
That was helpful. 😄
I'll get back to it. (Probably next weekend.)
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, any updates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No... sorry.
I've opened another issue to work on this.
Haven't found the time for it so far. 😞