fix(html/parser): Fix parsing of CDATA in the svg context (#6620)

This commit is contained in:
Alexander Akait 2022-12-12 08:05:40 +03:00 committed by GitHub
parent c74ca2f23f
commit 19c2ee593d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 79 deletions

View File

@ -533,12 +533,7 @@ where
fn run(&mut self) -> PResult<()> {
while !self.stopped {
let adjusted_current_node = self.get_adjusted_current_node();
let is_element_in_html_namespace =
if is_element_in_html_namespace(adjusted_current_node) {
true
} else {
is_html_integration_point(adjusted_current_node)
};
let is_element_in_html_namespace = is_element_in_html_namespace(adjusted_current_node);
self.input
.set_adjusted_current_node_to_html_namespace(is_element_in_html_namespace);

View File

@ -63,16 +63,15 @@
| <svg foreignObject>
| height="100px"
| width="100px"
| <!-- [CDATA[content]] -->
| "a"
| "contenta"
| "
"
| <svg desc>
| <!-- [CDATA[content]] -->
| "content"
| "
"
| <svg title>
| <!-- [CDATA[content]] -->
| "content"
| "
"
| "

View File

@ -577,25 +577,15 @@
}
],
"children": [
{
"type": "Comment",
"span": {
"start": 485,
"end": 504,
"ctxt": 0
},
"data": "[CDATA[content]]",
"raw": "<![CDATA[content]]>"
},
{
"type": "Text",
"span": {
"start": 504,
"start": 485,
"end": 505,
"ctxt": 0
},
"data": "a",
"raw": "a"
"data": "contenta",
"raw": "contenta"
}
],
"content": null,
@ -623,14 +613,14 @@
"attributes": [],
"children": [
{
"type": "Comment",
"type": "Text",
"span": {
"start": 532,
"end": 551,
"end": 548,
"ctxt": 0
},
"data": "[CDATA[content]]",
"raw": "<![CDATA[content]]>"
"data": "content",
"raw": "content"
}
],
"content": null,
@ -658,14 +648,14 @@
"attributes": [],
"children": [
{
"type": "Comment",
"type": "Text",
"span": {
"start": 570,
"end": 589,
"end": 586,
"ctxt": 0
},
"data": "[CDATA[content]]",
"raw": "<![CDATA[content]]>"
"data": "content",
"raw": "content"
}
],
"content": null,

View File

@ -86,27 +86,3 @@
: ^
18 | <svg viewBox="0 0 100 100">
`----
x Cdata in html content
,-[$DIR/tests/recovery/text/cdata/input.html:18:1]
18 | <svg viewBox="0 0 100 100">
19 | <foreignObject width="100px" height="100px"><![CDATA[content]]>a</foreignObject>
: ^
20 | <desc><![CDATA[content]]></desc>
`----
x Cdata in html content
,-[$DIR/tests/recovery/text/cdata/input.html:19:1]
19 | <foreignObject width="100px" height="100px"><![CDATA[content]]>a</foreignObject>
20 | <desc><![CDATA[content]]></desc>
: ^
21 | <title><![CDATA[content]]></title>
`----
x Cdata in html content
,-[$DIR/tests/recovery/text/cdata/input.html:20:1]
20 | <desc><![CDATA[content]]></desc>
21 | <title><![CDATA[content]]></title>
: ^
22 | </svg>
`----

View File

@ -889,23 +889,7 @@
,-[$DIR/tests/recovery/text/cdata/input.html:18:1]
18 | <svg viewBox="0 0 100 100">
19 | <foreignObject width="100px" height="100px"><![CDATA[content]]>a</foreignObject>
: ^^^^^^^^^^^^^^^^^^^
20 | <desc><![CDATA[content]]></desc>
`----
x Comment
,-[$DIR/tests/recovery/text/cdata/input.html:18:1]
18 | <svg viewBox="0 0 100 100">
19 | <foreignObject width="100px" height="100px"><![CDATA[content]]>a</foreignObject>
: ^^^^^^^^^^^^^^^^^^^
20 | <desc><![CDATA[content]]></desc>
`----
x Child
,-[$DIR/tests/recovery/text/cdata/input.html:18:1]
18 | <svg viewBox="0 0 100 100">
19 | <foreignObject width="100px" height="100px"><![CDATA[content]]>a</foreignObject>
: ^
: ^^^^^^^^^^^^^^^^^^^^
20 | <desc><![CDATA[content]]></desc>
`----
@ -913,7 +897,7 @@
,-[$DIR/tests/recovery/text/cdata/input.html:18:1]
18 | <svg viewBox="0 0 100 100">
19 | <foreignObject width="100px" height="100px"><![CDATA[content]]>a</foreignObject>
: ^
: ^^^^^^^^^^^^^^^^^^^^
20 | <desc><![CDATA[content]]></desc>
`----
@ -953,15 +937,15 @@
,-[$DIR/tests/recovery/text/cdata/input.html:19:1]
19 | <foreignObject width="100px" height="100px"><![CDATA[content]]>a</foreignObject>
20 | <desc><![CDATA[content]]></desc>
: ^^^^^^^^^^^^^^^^^^^
: ^^^^^^^^^^^^^^^^
21 | <title><![CDATA[content]]></title>
`----
x Comment
x Text
,-[$DIR/tests/recovery/text/cdata/input.html:19:1]
19 | <foreignObject width="100px" height="100px"><![CDATA[content]]>a</foreignObject>
20 | <desc><![CDATA[content]]></desc>
: ^^^^^^^^^^^^^^^^^^^
: ^^^^^^^^^^^^^^^^
21 | <title><![CDATA[content]]></title>
`----
@ -1001,15 +985,15 @@
,-[$DIR/tests/recovery/text/cdata/input.html:20:1]
20 | <desc><![CDATA[content]]></desc>
21 | <title><![CDATA[content]]></title>
: ^^^^^^^^^^^^^^^^^^^
: ^^^^^^^^^^^^^^^^
22 | </svg>
`----
x Comment
x Text
,-[$DIR/tests/recovery/text/cdata/input.html:20:1]
20 | <desc><![CDATA[content]]></desc>
21 | <title><![CDATA[content]]></title>
: ^^^^^^^^^^^^^^^^^^^
: ^^^^^^^^^^^^^^^^
22 | </svg>
`----