Skip to content

x/net: regression in x/net/html package: The <!--[if mso]--> email HTML comments are now being escaped #58246

Closed
@VojtechVitek

Description

@VojtechVitek

Hi,

We're rendering HTML emails in Go. We're using github.com/aymerick/douceur to do CSS inlining / HTML sanitization, which in turn uses golang.org/x/net/html package under the hood.

Recently, after upgrading x/net package, we have noticed that our HTML emails broke in certain email clients, ie. Windows / Microsoft Outlook, and rendered as a blank page.

We're using some Outlook-specific conditional comments in the HTML of our emails:

Example:

<!--[if gte mso 12]>
  <xml>
      <o:OfficeDocumentSettings>
      <o:AllowPNG/>
      <o:PixelsPerInch>96</o:PixelsPerInch>
      </o:OfficeDocumentSettings>
    </xml>
<![endif]-->

However, after this commit (#48237), the content of the HTML comments changed and is now being escaped:

<!--[if gte mso 12]&gt;
  &lt;xml&gt;
      &lt;o:OfficeDocumentSettings&gt;
      &lt;o:AllowPNG/&gt;
      &lt;o:PixelsPerInch&gt;96&lt;/o:PixelsPerInch&gt;
      &lt;/o:OfficeDocumentSettings&gt;
    &lt;/xml&gt;
&lt;![endif]-->

Emails are hard and it's quite normal to rely on these special <!--[if mso]> HTML comments to support Microsoft Outlook properly. See Targeting specific Outlook versions.

Questions:

  1. Is there any chance we could revert this change?
  2. Is there any chance we could provide a setting to turn off HTML comment escaping?
  3. Or should we consider this a breaking change "by design" and try to work around the issue (ie. by forking x/net/html)?

Thank you for your input.

Best,
Vojtech

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions