Skip to content
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

Outlook VML statements become commented #819

Closed
markb-trustifi opened this issue Jun 22, 2023 · 3 comments
Closed

Outlook VML statements become commented #819

markb-trustifi opened this issue Jun 22, 2023 · 3 comments

Comments

@markb-trustifi
Copy link

markb-trustifi commented Jun 22, 2023

Background & Context

Commented Outlook VML statements remain as is. Uncommented Outlook VML statements become commented.

dompurify: 3.0.1
jsdom: 22.1

Bug

Input

<!--[if gte vml 1]>
<v:shape id="Picture_x0020_2074" o:spid="_x0000_s1516" type="#_x0000_t75" style='position:absolute;margin-left:85.5pt;margin-top:0;width:322.5pt;height:0;z-index:252065792;visibility:visible;mso-wrap-style:square;mso-width-percent:0;mso-height-percent:0;mso-wrap-distance-left:9pt;mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;mso-wrap-distance-bottom:0;mso-position-horizontal:absolute;mso-position-horizontal-relative:text;mso-position-vertical:absolute;mso-position-vertical-relative:text;mso-width-percent:0;mso-height-percent:0;mso-width-relative:page;mso-height-relative:page'>
  <v:imagedata src="cid:[email protected]" o:title="~AUT0002" />
</v:shape>
<![endif]-->
<![if !vml]>
<span style="mso-ignore:vglayout;position:absolute;z-index:252065792;margin-left:371px;margin-top:154px;width:645px;height:1px">
  <img width="430" height="1" style="width:4.4791in;height:.0069in" src="cid:[email protected]" v:shapes="Picture_x0020_2074">
</span>
<![endif]>
let cfg = {
   WHOLE_DOCUMENT: true,
   ADD_TAGS: ['#comment'],
   FORBID_TAGS: ['noscript']
};
const virtualConsole = new jsdom.VirtualConsole();
const windowShim = new jsdom.JSDOM('', {resources: "usable", virtualConsole: virtualConsole}).window;
const DOMPurify = dompurify(windowShim);
stripedHtml = DOMPurify.sanitize(html, cfg);

Given output

<!--[if gte vml 1]>
<v:shape id="Picture_x0020_2074" o:spid="_x0000_s1516" type="#_x0000_t75" style='position:absolute;margin-left:85.5pt;margin-top:0;width:322.5pt;height:0;z-index:252065792;visibility:visible;mso-wrap-style:square;mso-width-percent:0;mso-height-percent:0;mso-wrap-distance-left:9pt;mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;mso-wrap-distance-bottom:0;mso-position-horizontal:absolute;mso-position-horizontal-relative:text;mso-position-vertical:absolute;mso-position-vertical-relative:text;mso-width-percent:0;mso-height-percent:0;mso-width-relative:page;mso-height-relative:page'>
  <v:imagedata src="cid:[email protected]" o:title="~AUT0002" />
</v:shape>
<![endif]-->
<!--[if !vml]-->
<span style="mso-ignore:vglayout;position:absolute;z-index:252065792;margin-left:371px;margin-top:154px;width:645px;height:1px">
<img src="cid:6e7d3681a84b7f1bbf21103b297ed1a0" style="width:4.4791in;height:.0069in" height="1" width="430">
</span>
<!--[endif]-->

Expected output

Everything should remain unchanged

@cure53
Copy link
Owner

cure53 commented Jun 24, 2023

There is sadly not easy way to fix this behavior. The weird Outlook VML statements are non-standard HTML and naturally will e removed. maybe you can write a hook to better control this behavior - but no changes in the core library are expected to handle this.

@cure53
Copy link
Owner

cure53 commented Jun 25, 2023

Closing this now as this is not a bug we can fix and not much we can do here.

@markb-trustifi
Copy link
Author

FYI, there is a related ticket inikulin/parse5#963

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants