1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 18:54:57 +00:00

LibHTML: Parse <element attribute=value> correctly

We were not committing the attribute at all in this case.
This commit is contained in:
Andreas Kling 2019-11-21 20:18:18 +01:00
parent 8946e50986
commit c02f560f73

View file

@ -281,6 +281,21 @@ static bool parse_html_document(const StringView& html, Document& document, Pare
move_to_state(State::InAttributeList);
break;
}
move_to_state(State::InAttributeValueNoQuote);
[[fallthrough]];
case State::InAttributeValueNoQuote:
if (isspace(ch)) {
commit_attribute();
move_to_state(State::InAttributeList);
break;
}
if (ch == '>') {
commit_attribute();
commit_tag();
move_to_state(State::Free);
break;
}
attribute_value_buffer.append(ch);
break;
case State::InAttributeValueSingleQuote:
if (ch == '\'') {
@ -298,19 +313,6 @@ static bool parse_html_document(const StringView& html, Document& document, Pare
}
attribute_value_buffer.append(ch);
break;
case State::InAttributeValueNoQuote:
if (isspace(ch)) {
commit_attribute();
move_to_state(State::InAttributeList);
break;
}
if (ch == '>') {
commit_tag();
move_to_state(State::Free);
break;
}
attribute_value_buffer.append(ch);
break;
default:
fprintf(stderr, "Unhandled state %d\n", (int)state);
ASSERT_NOT_REACHED();