Skip to content
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

Deny Unicode Escapes in boolean and null expressions #2931

Merged
merged 2 commits into from
May 31, 2023

Conversation

veera-sivarajan
Copy link
Contributor

This Pull Request fixes/closes #2771.

This PR keeps track of ContainsEscapeSequence in all TokenKind::BooleanLiteral and TokenKind::NullLiteral and throws an error when it gets parsed as an expression.

Opening a different PR for this since I messed up the commit history of the previous PR.

@codecov
Copy link

codecov bot commented May 16, 2023

Codecov Report

Merging #2931 (8172596) into main (d13979d) will decrease coverage by 1.70%.
The diff coverage is 38.88%.

@@            Coverage Diff             @@
##             main    #2931      +/-   ##
==========================================
- Coverage   52.09%   50.39%   -1.70%     
==========================================
  Files         435      443       +8     
  Lines       43713    45346    +1633     
==========================================
+ Hits        22771    22851      +80     
- Misses      20942    22495    +1553     
Impacted Files Coverage Δ
boa_parser/src/lexer/token.rs 48.57% <0.00%> (ø)
...a_parser/src/parser/expression/assignment/yield.rs 34.54% <0.00%> (ø)
...arser/expression/primary/object_initializer/mod.rs 63.75% <0.00%> (ø)
...ser/src/parser/expression/left_hand_side/member.rs 52.89% <14.28%> (+1.27%) ⬆️
...arser/src/parser/expression/left_hand_side/call.rs 46.77% <25.00%> (+2.15%) ⬆️
boa_parser/src/parser/expression/primary/mod.rs 54.59% <40.00%> (+0.88%) ⬆️
boa_parser/src/lexer/identifier.rs 91.80% <50.00%> (-4.75%) ⬇️
...c/parser/expression/left_hand_side/optional/mod.rs 79.36% <100.00%> (-0.64%) ⬇️
.../statement/declaration/hoistable/class_decl/mod.rs 50.65% <100.00%> (-0.06%) ⬇️

... and 70 files with indirect coverage changes

@HalidOdat
Copy link
Member

Test result main count PR count difference
Total 94,657 94,657 0
Passed 73,901 73,901 0
Ignored 17,505 17,505 0
Failed 3,251 3,251 0
Panics 0 0 0
Conformance 78.07% 78.07% 0.00%

@raskad
Copy link
Member

raskad commented May 18, 2023

Since there seems to be not explicit test for this in the 262 suite, could you add some tests for this that make sure the parser produces syntax errors in these cases?

Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, check my comment to see on how we might improve this :)

boa_parser/src/lexer/token.rs Show resolved Hide resolved
@HalidOdat HalidOdat requested a review from a team May 24, 2023 15:55
@HalidOdat HalidOdat added bug Something isn't working parser Issues surrounding the parser labels May 24, 2023
@HalidOdat HalidOdat added this to the v0.17.0 milestone May 24, 2023
Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! @veera-sivarajan Looks perfect to me! :)

@Razican
Copy link
Member

Razican commented May 27, 2023

Since there seems to be not explicit test for this in the 262 suite, could you add some tests for this that make sure the parser produces syntax errors in these cases?

Should we try to add such a test to Test262, or report it at least?

@veera-sivarajan
Copy link
Contributor Author

Since there seems to be not explicit test for this in the 262 suite, could you add some tests for this that make sure the parser produces syntax errors in these cases?

Should we try to add such a test to Test262, or report it at least?

I have opened a PR for the same.

Copy link
Member

@raskad raskad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice job, great contribution!

@raskad raskad added this pull request to the merge queue May 31, 2023
Merged via the queue into boa-dev:main with commit 4a68fb5 May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser Issues surrounding the parser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keywords with Unicode escapes should throw syntax errors
4 participants