Skip to content

Commit 202bfab

Browse files
alimpfardtcl3
authored andcommitted
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>
1 parent 70e769a commit 202bfab

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Userland/Libraries/LibXML/Parser/Parser.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ ErrorOr<void, ParseError> Parser::parse_element()
617617
return {};
618618
}
619619

620+
auto accept = accept_rule();
620621
auto start_tag = TRY(parse_start_tag());
621622
auto& node = *start_tag;
622623
auto& tag = node.content.get<Node::Element>();
@@ -649,7 +650,6 @@ ErrorOr<NonnullOwnPtr<Node>, ParseError> Parser::parse_empty_element_tag()
649650
// EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
650651
auto tag_start = m_lexer.tell();
651652
TRY(expect("<"sv));
652-
auto accept = accept_rule();
653653

654654
auto name = TRY(parse_name());
655655
HashMap<Name, ByteString> attributes;
@@ -669,6 +669,8 @@ ErrorOr<NonnullOwnPtr<Node>, ParseError> Parser::parse_empty_element_tag()
669669
TRY(skip_whitespace());
670670
TRY(expect("/>"sv));
671671

672+
auto accept = accept_rule();
673+
672674
rollback.disarm();
673675
return make<Node>(m_lexer.position_for(tag_start), Node::Element { move(name), move(attributes), {} });
674676
}
@@ -848,6 +850,7 @@ ErrorOr<void, ParseError> Parser::parse_content()
848850
{
849851
auto rollback = rollback_point();
850852
auto rule = enter_rule();
853+
auto accept = accept_rule();
851854

852855
// content ::= CharData? ((element | Reference | CDSect | PI | Comment) CharData?)*
853856
auto content_start = m_lexer.tell();

0 commit comments

Comments
 (0)