Skip to content

Fix <form> handling in table and body - #83

Open
tysg wants to merge 3 commits into
aantron:masterfrom
ahrefs:parser-fix-1
Open

Fix <form> handling in table and body#83
tysg wants to merge 3 commits into
aantron:masterfrom
ahrefs:parser-fix-1

Conversation

@tysg

@tysg tysg commented Dec 6, 2024

Copy link
Copy Markdown

We discovered some divergence from spec in <form> tag handling and a typo in reset_mode, while investigating an edge case where the parser enters an infinite loop (ahrefs@8cca065). This PR fixes the divergence.

https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-intable

A start tag whose tag name is "form"

Parse error.
If there is a template element on the stack of open elements, or if the form element pointer is not null, ignore the token.

Otherwise:
Insert an HTML element for the token, and set the form element pointer to point to the element created.
Pop that form element off the stack of open elements.

https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inbody

An end tag whose tag name is "form"

If there is no template element on the stack of open elements, then run these substeps:

Let node be the element that the form element pointer is set to, or null if it is not set to an element.
Set the form element pointer to null.
If node is null or if the stack of open elements does not have node in scope, then this is a parse error; return and ignore the token.
Generate implied end tags.
If the current node is not node, then this is a parse error.
Remove node from the stack of open elements.

If there is a template element on the stack of open elements, then run these substeps instead:
If the stack of open elements does not have a form element in scope, then this is a parse error; return and ignore the token.
Generate implied end tags.
If the current node is not a form element, then this is a parse error.
Pop elements from the stack of open elements until a form element has been popped from the stack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants