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

Fix breaking preprocessors' directives when parsing attributes #171

Merged
merged 3 commits into from Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/dom.js
Expand Up @@ -1064,7 +1064,7 @@ function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
}
return;
case ATTRIBUTE_NODE:
return buf.push(' ',node.name,'="',node.value.replace(/[<&"]/g,_xmlEncoder),'"');
return buf.push(' ',node.name,'="',node.value.replace(/[&"]/g,_xmlEncoder),'"');
case TEXT_NODE:
return buf.push(node.data.replace(/[<&]/g,_xmlEncoder));
case CDATA_SECTION_NODE:
Expand Down
6 changes: 3 additions & 3 deletions test/html/__snapshots__/normalize.test.js.snap
Expand Up @@ -40,13 +40,13 @@ Object {

exports[`html normalizer <div test="a<b&&a< c && a>d"></div> 1`] = `
Object {
"actual": "<div test=\\"a&lt;b&amp;&amp;a&lt; c &amp;&amp; a>d\\" xmlns=\\"http://www.w3.org/1999/xhtml\\"></div>",
"actual": "<div test=\\"a<b&amp;&amp;a< c &amp;&amp; a>d\\" xmlns=\\"http://www.w3.org/1999/xhtml\\"></div>",
}
`;

exports[`html normalizer <div test="alert('<br/>')"/> 1`] = `
Object {
"actual": "<div test=\\"alert('&lt;br/>')\\" xmlns=\\"http://www.w3.org/1999/xhtml\\"></div>",
"actual": "<div test=\\"alert('<br/>')\\" xmlns=\\"http://www.w3.org/1999/xhtml\\"></div>",
}
`;

Expand Down Expand Up @@ -86,7 +86,7 @@ Object {

exports[`html normalizer <html test="a<b && a>b && '&amp;&&'"/> 1`] = `
Object {
"actual": "<html test=\\"a&lt;b &amp;&amp; a>b &amp;&amp; '&amp;&amp;&amp;'\\" xmlns=\\"http://www.w3.org/1999/xhtml\\"></html>",
"actual": "<html test=\\"a<b &amp;&amp; a>b &amp;&amp; '&amp;&amp;&amp;'\\" xmlns=\\"http://www.w3.org/1999/xhtml\\"></html>",
}
`;

Expand Down
2 changes: 1 addition & 1 deletion test/parse/__snapshots__/locator.test.js.snap
Expand Up @@ -2,7 +2,7 @@

exports[`DOMLocator attribute position 1`] = `
Object {
"actual": "<html xmlns=\\"http://www.w3.org/1999/xhtml\\"><body title=\\"1&lt;2\\"><table></table>&lt;;test</body></html>",
"actual": "<html xmlns=\\"http://www.w3.org/1999/xhtml\\"><body title=\\"1<2\\"><table></table>&lt;;test</body></html>",
}
`;

Expand Down
4 changes: 2 additions & 2 deletions test/parse/__snapshots__/simple.test.js.snap
Expand Up @@ -12,7 +12,7 @@ Object {

exports[`parse simple 1`] = `
Object {
"actual": "<html xmlns=\\"http://www.w3.org/1999/xhtml\\"><body title=\\"1&lt;2\\"></body></html>",
"actual": "<html xmlns=\\"http://www.w3.org/1999/xhtml\\"><body title=\\"1<2\\"></body></html>",
}
`;

Expand Down Expand Up @@ -49,6 +49,6 @@ Object {

exports[`parse wrong closing tag 1`] = `
Object {
"actual": "<html xmlns=\\"http://www.w3.org/1999/xhtml\\"><body title=\\"1&lt;2\\"><table></table>&lt;;test</body></html>",
"actual": "<html xmlns=\\"http://www.w3.org/1999/xhtml\\"><body title=\\"1<2\\"><table></table>&lt;;test</body></html>",
}
`;
2 changes: 1 addition & 1 deletion test/xmltest/__snapshots__/not-wf.test.js.snap
Expand Up @@ -112,7 +112,7 @@ Object {

exports[`xmltest/not-wellformed standalone should match 014.xml with snapshot 1`] = `
Object {
"actual": "<doc a1=\\"&lt;foo>\\"/>",
"actual": "<doc a1=\\"<foo>\\"/>",
}
`;

Expand Down
2 changes: 1 addition & 1 deletion test/xmltest/__snapshots__/valid.test.js.snap
Expand Up @@ -293,7 +293,7 @@ Object {

exports[`xmltest/valid standalone should match 040.xml with snapshot 1`] = `
Object {
"actual": "<doc a1=\\"&quot;&lt;&amp;>'\\"/>",
"actual": "<doc a1=\\"&quot;<&amp;>'\\"/>",
"expected": "<doc a1=\\"&quot;&lt;&amp;&gt;'\\"></doc>",
}
`;
Expand Down