After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 714452 - Elements of <head> in email end up in body of document in ConversationWebView
Elements of <head> in email end up in body of document in ConversationWebView
Status: RESOLVED FIXED
Product: geary
Classification: Other
Component: conversations
0.4.0
Other All
: Normal normal
: ---
Assigned To: Robert Schroll
Geary Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-05-03 10:01 UTC by Robert Schroll
Modified: 2013-05-21 08:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
0001-Include-only-the-body-of-full-HTML-emails.patch (1.68 KB, application/x-download)
2013-05-18 16:44 UTC, Robert Schroll
Details
new patch obsoletes previous (1.68 KB, application/x-download)
2013-05-20 06:18 UTC, Robert Schroll
Details

Description Charles Lindsay 2013-11-21 20:26:47 UTC


---- Reported by rschroll@gmail.com 2013-05-03 15:01:00 -0700 ----

Original Redmine bug id: 6896
Original URL: http://redmine.yorba.org/issues/6896
Searchable id: yorba-bug-6896
Original author: Robert Schroll
Original description:

I just got a HTML email that was a full HTML document, with a head and a body.
When I inspect the conversation, I find that all the elements that had been in
the head of the email ended up in the div.body of the email. The bad thing
about this is that the email included an in-line style sheet in its head,
which proceeded to change the font size for the headers as well as the body.
We shouldn't allow that.

ConversationViewer.insert_html_markup() has code that would seem to only
included the body of such emails, but that didn't seem to have worked. It's
supposed to work by inserting all of the HTML and then looking for a body
element. My guess (untested at the moment) is that when the HTML was inserted,
WebKit decided that the head and body elements weren't permitted where they
were inserted, and helpfully stripped them out.

We could work around this by using regexes to look for and strip down to the
body element before we insert the HTML into the DOM.

A related issue is whether we should allow style elements into our DOM at all.
We could try to adjust their rules so that they only act on the email they're
in, but it'd be easier just to strip them out completely.

Related issues:
related to geary - 7298: Malformed HTML email gets cut off partway
through (Open)
duplicates geary - 5440: Header labels are affected by message body (Open)



---- Additional Comments From geary-maint@gnome.bugs 2013-05-21 13:28:00 -0700 ----

### History

####

#1

Updated by Eric Gregory 7 months ago

A number of newsletters I've seen use CSS for styling.

Seems to me the ideal solution would be to replace html and body elements with
something else (divs?) and re-write the CSS rules so that they impact the new
elements instead of html and body.

####

#2

Updated by Jim Nelson 7 months ago

  * **Status** changed from _Open_ to _Duplicate_

This is a duplicate of #5440.

I regularly get emails from one of the mailing lists I'm on that exhibits this
bug.

####

#3

Updated by Robert Schroll 7 months ago

As I see it, there are two mostly-distinct issues here:

1) Elements in the head of a HTML email end up in the body of the document.

2) CSS rules in style elements in HTML emails end up affecting everything

There's some interaction, since style elements usually come in the head, so if
(1) weren't a problem we wouldn't notice (2). Nonetheless, each can be solved
on its own. My recommendation is to deal with (1) in this issue, and handle
(2) in #5440.

####

#4

Updated by Jim Nelson 7 months ago

  * **Status** changed from _Duplicate_ to _Open_

That seems reasonable, so I'll re-open this. Hopefully both can be solved at
(approximately) the same time.

####

#5

Updated by Robert Schroll 6 months ago

  * **File** 0001-Include-only-the-body-of-full-HTML-emails.patch added
  * **Status** changed from _Open_ to _Review_
  * **Assignee** set to _Robert Schroll_

This patch checks if the HTML email has a <body>. If so, only the contents of
the body are used. As a bonus, if the body tag as attributes (like style),
these are transferred to a <div> surrounding the contents.

It does not transfer <style> tags from the <head> of the email, as
(accidentally) happens now. My feeling is to hold off on this until #5440 is
ready to properly restrict them, but we could put them in now and be no worse
off than we are now.

####

#6

Updated by Robert Schroll 6 months ago

  * **File** 0001-Include-only-the-body-of-full-HTML-emails.patch added

Oops. Not sure how I missed this in testing.

####

#7

Updated by Jim Nelson 6 months ago

  * **Target version** set to _0.4.0_

Robert, this is great and solves the email problem I mentioned in comment 2.
Thanks!

####

#8

Updated by Robert Schroll 6 months ago

  * **Status** changed from _Review_ to _Fixed_

Applied in changeset c170ad1b4a1d94c41f15dc3ffc344f8042cd2409.



--- Bug imported by chaz@yorba.org 2013-11-21 20:26 UTC  ---

This bug was previously known as _bug_ 6896 at http://redmine.yorba.org/show_bug.cgi?id=6896
Imported an attachment (id=260988)
Imported an attachment (id=260989)

Unknown milestone "unknown in product geary. 
   Setting to default milestone for this product, "---".
Setting qa contact to the default for this product.
   This bug either had no qa contact or an invalid one.