Browse Source

LibHTML: Parse <element attribute=value> correctly

We were not committing the attribute at all in this case.
Andreas Kling 5 years ago
parent
commit
c02f560f73
1 changed files with 14 additions and 12 deletions
  1. 14 12
      Libraries/LibHTML/Parser/HTMLParser.cpp

+ 14 - 12
Libraries/LibHTML/Parser/HTMLParser.cpp

@@ -281,34 +281,36 @@ static bool parse_html_document(const StringView& html, Document& document, Pare
                 move_to_state(State::InAttributeList);
                 break;
             }
-            break;
-        case State::InAttributeValueSingleQuote:
-            if (ch == '\'') {
+            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::InAttributeValueDoubleQuote:
-            if (ch == '"') {
+        case State::InAttributeValueSingleQuote:
+            if (ch == '\'') {
                 commit_attribute();
                 move_to_state(State::InAttributeList);
                 break;
             }
             attribute_value_buffer.append(ch);
             break;
-        case State::InAttributeValueNoQuote:
-            if (isspace(ch)) {
+        case State::InAttributeValueDoubleQuote:
+            if (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: