Skip to content

Parsing html output from xss filter dosen't work #152

@fredrik-sogaard

Description

@fredrik-sogaard

Expected Behavior

I use https://github.com/leizongmin/js-xss to do some sanitation of the my html before parsing it and making React elements. I except the sanitized html to be parsed correctly into elements.

Actual Behavior

The html I want to sanitize and parse is this:

<meta name="keywords" content="dette, introfeltet">
<meta name="description" content="Dette er introfeltet.">
<meta name="referrer" content="no-referrer-when-downgrade">
<meta name="robots" content="none">
<meta content="nb_NO" property="og:locale">
<meta content="en_EN" property="og:locale:alternate">
<meta content="nb_NO" property="og:locale:alternate">
<meta content="Samskipnaden Craft" property="og:site_name">
...

Run through the xxs filter I get this:

&lt;meta name="keywords" content="dette, introfeltet"&gt;
&lt;meta name="description" content="Dette er introfeltet."&gt;
&lt;meta name="referrer" content="no-referrer-when-downgrade"&gt;
&lt;meta name="robots" content="none"&gt;
&lt;meta content="nb_NO" property="og:locale"&gt;
&lt;meta content="en_EN" property="og:locale:alternate"&gt;
&lt;meta content="nb_NO" property="og:locale:alternate"&gt;
&lt;meta content="Samskipnaden Craft" property="og:site_name"&gt;
...

Run through the html parser I only get at string back looking exactly like the original html—no React elements. Should the parser correctly parse sanitized html?

Parsing the original html gets me the expected React elements.

Steps to Reproduce

Install https://github.com/leizongmin/js-xss and filter some html before parsing it.

Reproducible Demo

Environment

  • Version: 0.10.3
  • Platform: Node / Next JS
  • Browser: / Chrome 81

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions