LibXML: Shift some rule acceptances to make errors nicer
Instead of saying "expected />", make the parser output the real cause for the following ("unknown reference"): <foo>&unknown;</foo>
This commit is contained in:
parent
70e769a18a
commit
202bfabdc6
Notes:
github-actions[bot]
2024-10-10 22:54:45 +00:00
Author: https://github.com/alimpfard Commit: https://github.com/LadybirdBrowser/ladybird/commit/202bfabdc6c Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1710 Reviewed-by: https://github.com/DanShaders ✅ Reviewed-by: https://github.com/tcl3 ✅
1 changed files with 4 additions and 1 deletions
|
@ -617,6 +617,7 @@ ErrorOr<void, ParseError> Parser::parse_element()
|
|||
return {};
|
||||
}
|
||||
|
||||
auto accept = accept_rule();
|
||||
auto start_tag = TRY(parse_start_tag());
|
||||
auto& node = *start_tag;
|
||||
auto& tag = node.content.get<Node::Element>();
|
||||
|
@ -649,7 +650,6 @@ ErrorOr<NonnullOwnPtr<Node>, ParseError> Parser::parse_empty_element_tag()
|
|||
// EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
|
||||
auto tag_start = m_lexer.tell();
|
||||
TRY(expect("<"sv));
|
||||
auto accept = accept_rule();
|
||||
|
||||
auto name = TRY(parse_name());
|
||||
HashMap<Name, ByteString> attributes;
|
||||
|
@ -669,6 +669,8 @@ ErrorOr<NonnullOwnPtr<Node>, ParseError> Parser::parse_empty_element_tag()
|
|||
TRY(skip_whitespace());
|
||||
TRY(expect("/>"sv));
|
||||
|
||||
auto accept = accept_rule();
|
||||
|
||||
rollback.disarm();
|
||||
return make<Node>(m_lexer.position_for(tag_start), Node::Element { move(name), move(attributes), {} });
|
||||
}
|
||||
|
@ -848,6 +850,7 @@ ErrorOr<void, ParseError> Parser::parse_content()
|
|||
{
|
||||
auto rollback = rollback_point();
|
||||
auto rule = enter_rule();
|
||||
auto accept = accept_rule();
|
||||
|
||||
// content ::= CharData? ((element | Reference | CDSect | PI | Comment) CharData?)*
|
||||
auto content_start = m_lexer.tell();
|
||||
|
|
Loading…
Add table
Reference in a new issue