-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Ensure } and { are valid boundary characters
#17001
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
41eecaa
add `assert_extract_candidates_contains` helper
RobinMalfait 84f3fe3
add failing test for `twig` syntax
RobinMalfait ea2eec5
ensure `}…{` are valid boundary characters
RobinMalfait 7258503
cleanup unused import
RobinMalfait 609b0af
update changelog
RobinMalfait 0002af6
re-use `is_valid_after_boundary`
RobinMalfait f0ba1d2
add additional test case
RobinMalfait b5cfa04
drop `pug syntax` tests from `utility_machine`
RobinMalfait 7f93659
accept `class` in `<div class="…">`
RobinMalfait 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 hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| use crate::cursor; | ||
| use crate::extractor::arbitrary_value_machine::ArbitraryValueMachine; | ||
| use crate::extractor::arbitrary_variable_machine::ArbitraryVariableMachine; | ||
| use crate::extractor::candidate_machine::is_valid_after_boundary; | ||
| use crate::extractor::machine::{Machine, MachineState}; | ||
| use classification_macros::ClassifyBytes; | ||
|
|
||
|
|
@@ -120,19 +121,22 @@ impl Machine for NamedUtilityMachine { | |
| // E.g.: `:div="{ flex: true }"` (JavaScript object syntax) | ||
| // ^ | ||
| Class::AlphaLower | Class::AlphaUpper => { | ||
| match cursor.next.into() { | ||
| Class::Quote | ||
| | Class::Whitespace | ||
| | Class::CloseBracket | ||
| | Class::Dot | ||
| | Class::Colon | ||
| | Class::End | ||
| | Class::Slash | ||
| | Class::Exclamation => return self.done(self.start_pos, cursor), | ||
|
|
||
| // Still valid characters | ||
| _ => cursor.advance(), | ||
| if is_valid_after_boundary(&cursor.next) || { | ||
| // Or any of these characters | ||
| // | ||
| // - `:`, because of JS object keys | ||
| // - `/`, because of modifiers | ||
| // - `!`, because of important | ||
| matches!( | ||
| cursor.next.into(), | ||
| Class::Colon | Class::Slash | Class::Exclamation | ||
| ) | ||
| } { | ||
| return self.done(self.start_pos, cursor); | ||
| } | ||
|
|
||
| // Still valid characters | ||
| cursor.advance() | ||
| } | ||
|
|
||
| Class::Dash => match cursor.next.into() { | ||
|
|
@@ -213,14 +217,20 @@ impl Machine for NamedUtilityMachine { | |
| // ^ | ||
| // E.g.: `:div="{ flex: true }"` (JavaScript object syntax) | ||
| // ^ | ||
| Class::Quote | ||
| | Class::Whitespace | ||
| | Class::CloseBracket | ||
| | Class::Dot | ||
| | Class::Colon | ||
| | Class::End | ||
| | Class::Slash | ||
| | Class::Exclamation => return self.done(self.start_pos, cursor), | ||
| _ if is_valid_after_boundary(&cursor.next) || { | ||
| // Or any of these characters | ||
| // | ||
| // - `:`, because of JS object keys | ||
| // - `/`, because of modifiers | ||
| // - `!`, because of important | ||
| matches!( | ||
| cursor.next.into(), | ||
| Class::Colon | Class::Slash | Class::Exclamation | ||
| ) | ||
| } => | ||
| { | ||
| return self.done(self.start_pos, cursor) | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto here too |
||
|
|
||
| // Everything else is invalid | ||
| _ => return self.restart(), | ||
|
|
||
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.
This is fine for now but we'll want to perf test this. I wouldn't be surprised if this implementation causes a bit of a hit
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.
Yep will do some classification next, and I still have a WIP branch to get rid of the Cursor