mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 07:41:01 +00:00
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: 202bfabdc6
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 {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto accept = accept_rule();
|
||||||
auto start_tag = TRY(parse_start_tag());
|
auto start_tag = TRY(parse_start_tag());
|
||||||
auto& node = *start_tag;
|
auto& node = *start_tag;
|
||||||
auto& tag = node.content.get<Node::Element>();
|
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? '/>'
|
// EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
|
||||||
auto tag_start = m_lexer.tell();
|
auto tag_start = m_lexer.tell();
|
||||||
TRY(expect("<"sv));
|
TRY(expect("<"sv));
|
||||||
auto accept = accept_rule();
|
|
||||||
|
|
||||||
auto name = TRY(parse_name());
|
auto name = TRY(parse_name());
|
||||||
HashMap<Name, ByteString> attributes;
|
HashMap<Name, ByteString> attributes;
|
||||||
|
@ -669,6 +669,8 @@ ErrorOr<NonnullOwnPtr<Node>, ParseError> Parser::parse_empty_element_tag()
|
||||||
TRY(skip_whitespace());
|
TRY(skip_whitespace());
|
||||||
TRY(expect("/>"sv));
|
TRY(expect("/>"sv));
|
||||||
|
|
||||||
|
auto accept = accept_rule();
|
||||||
|
|
||||||
rollback.disarm();
|
rollback.disarm();
|
||||||
return make<Node>(m_lexer.position_for(tag_start), Node::Element { move(name), move(attributes), {} });
|
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 rollback = rollback_point();
|
||||||
auto rule = enter_rule();
|
auto rule = enter_rule();
|
||||||
|
auto accept = accept_rule();
|
||||||
|
|
||||||
// content ::= CharData? ((element | Reference | CDSect | PI | Comment) CharData?)*
|
// content ::= CharData? ((element | Reference | CDSect | PI | Comment) CharData?)*
|
||||||
auto content_start = m_lexer.tell();
|
auto content_start = m_lexer.tell();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue