-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Continue parsing as data after invalid opening tag #253
Open
bsweeney
wants to merge
1
commit into
Masterminds:master
Choose a base branch
from
bsweeney:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, the parser would be in the 13.2.5.8 Tag name state - thus, form my POV the startTag should be
span<
and the text just02
.\Masterminds\HTML5\Parser\Tokenizer::consumeData
checks foris_alpha($tok)
and thus skips<
for the tag name. It seems the states are "optimized" in the current implementation.In general I think that the current state of the test is still fine (having
<>02
astext
).There might be a comment above the test that there is this divergence to the specs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the parser should be in tag name state, but tag name parsing does not quite follow the spec. It only consumes a restricted set of characters and then enters attribute state, where the spec indicates that the character should be part of the tag name. Attribute state parsing also does not quite follow the spec in that it exits as soon as it encounters the
<
, where the spec indicates it should be treated as part of an attribute name while in that state (thus<span <>02</span>
also does not produce the correct output). At this point the parser re-enters the data state and the character combo<>
does not match a known state and so is consumed as data. With the change to the data state handling the extra<
is exposed whereas before it was just swallowed.That was the meaning behind my comment in 250 that there are other issues to address. It took me a while to get the data state parsing right, so I didn't want to immediately dive into the parsing issues with the other states.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original issue is referencing problems in the data state and that was what I was attempting to address. Instead of a comment here, the parsing issues in tag name and attribute name could be addressed now in this PR or a new issue outlining the problem in those states could be opened with information about the divergence. I was primarily waiting to see what feedback I got on the current change before deciding whether to address those issues here or open a new issue and defer the additional work.