Skip to content

Commit

Permalink
Fix infinite loop with bad button close tag (flutter#128)
Browse files Browse the repository at this point in the history
Closes flutter#122

Add 'button' to the tags that are processed with `endTagBlock`. The spec
at https://html.spec.whatwg.org/multipage/parsing.html includes 'button'
in the list of end tags with this treatment.

Add a new `.dat` file for regression test. It include an `#info` field
which is new but can be parsed safely to mark the issue for which it is
a test. This test loops endlessly before the fix and passes after the
fix.

Note that since errors are currently untested and tests fail if they are
tested the error will be left without content for now.
  • Loading branch information
natebosch authored Sep 25, 2020
1 parent 2599afe commit 22f17e9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.14.0+4

- Fix a bug parsing bad HTML where a 'button' end tag needs to close other
elements.

## 0.14.0+3

- Fix spans generated for HTML with higher-plane unicode characters
Expand Down
1 change: 1 addition & 0 deletions lib/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,7 @@ class InBodyPhase extends Phase {
case 'article':
case 'aside':
case 'blockquote':
case 'button':
case 'center':
case 'details':
case 'dir':
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: html
version: 0.14.0+3
version: 0.14.0+4

description: APIs for parsing and manipulating HTML content outside the browser.
author: Dart Team <[email protected]>
Expand Down
13 changes: 13 additions & 0 deletions test/data/tree-construction/regression_tests.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#data
<button><p></button><button></button>
#info
Regression test for https://github.com/dart-lang/html/issues/122
#errors
Errors are currently untested: https://github.com/dart-lang/html/issues/127
#document
| <html>
| <head>
| <body>
| <button>
| <p>
| <button>

0 comments on commit 22f17e9

Please sign in to comment.