fix(html/parser): Fix error reporting related to image (#4720)

This commit is contained in:
Alexander Akait 2022-05-21 15:06:30 +03:00 committed by GitHub
parent db96405e8e
commit 4cee4ac238
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 124 additions and 4 deletions

View File

@ -3554,9 +3554,7 @@ where
ErrorKind::UnexpectedImageStartTag,
));
let mut new_token_and_info = token_and_info.clone();
match &mut new_token_and_info {
match token_and_info {
TokenAndInfo {
token: Token::StartTag { tag_name, .. },
..
@ -3568,7 +3566,7 @@ where
}
}
self.process_token(&mut new_token_and_info, None)?;
self.process_token(token_and_info, None)?;
}
// A start tag whose tag name is "textarea"
//

View File

@ -0,0 +1,5 @@
| <!DOCTYPE html>
| <html>
| <head>
| <body>
| <img>

View File

@ -0,0 +1 @@
<!doctype html><image/>

View File

@ -0,0 +1,76 @@
{
"type": "Document",
"span": {
"start": 1,
"end": 24,
"ctxt": 0
},
"mode": "no-quirks",
"children": [
{
"type": "DocumentType",
"span": {
"start": 1,
"end": 16,
"ctxt": 0
},
"name": "html",
"publicId": null,
"systemId": null
},
{
"type": "Element",
"span": {
"start": 0,
"end": 24,
"ctxt": 0
},
"tagName": "html",
"namespace": "http://www.w3.org/1999/xhtml",
"attributes": [],
"children": [
{
"type": "Element",
"span": {
"start": 0,
"end": 24,
"ctxt": 0
},
"tagName": "head",
"namespace": "http://www.w3.org/1999/xhtml",
"attributes": [],
"children": [],
"content": null
},
{
"type": "Element",
"span": {
"start": 0,
"end": 24,
"ctxt": 0
},
"tagName": "body",
"namespace": "http://www.w3.org/1999/xhtml",
"attributes": [],
"children": [
{
"type": "Element",
"span": {
"start": 16,
"end": 24,
"ctxt": 0
},
"tagName": "img",
"namespace": "http://www.w3.org/1999/xhtml",
"attributes": [],
"children": [],
"content": null
}
],
"content": null
}
],
"content": null
}
]
}

View File

@ -0,0 +1,6 @@
x Unexpected "<image>" start tag, only "<img>" tag exists in HTML
,-[$DIR/tests/recovery/element/image-1/input.html:1:1]
1 | <!doctype html><image/>
: ^^^^^^^^
`----

View File

@ -0,0 +1,34 @@
x Document
,-[$DIR/tests/recovery/element/image-1/input.html:1:1]
1 | <!doctype html><image/>
: ^^^^^^^^^^^^^^^^^^^^^^^
`----
x Child
,-[$DIR/tests/recovery/element/image-1/input.html:1:1]
1 | <!doctype html><image/>
: ^^^^^^^^^^^^^^^
`----
x DocumentType
,-[$DIR/tests/recovery/element/image-1/input.html:1:1]
1 | <!doctype html><image/>
: ^^^^^^^^^^^^^^^
`----
x Child
x Element
x Child
,-[$DIR/tests/recovery/element/image-1/input.html:1:1]
1 | <!doctype html><image/>
: ^^^^^^^^
`----
x Element
,-[$DIR/tests/recovery/element/image-1/input.html:1:1]
1 | <!doctype html><image/>
: ^^^^^^^^
`----