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

[Merged by Bors] - Fix regex literal /[/]/ #2277

Closed
wants to merge 1 commit into from

Conversation

tunz
Copy link
Contributor

@tunz tunz commented Sep 12, 2022

This PR fixes a case where a forward slash is located in a regex class: let regex = /[/]/;. In this case, the forward slash should not close the regex literal.

This fixes test/built-ins/RegExp/regexp-class-chars.js

@codecov
Copy link

codecov bot commented Sep 12, 2022

Codecov Report

Merging #2277 (9d7211b) into main (2072f51) will increase coverage by 0.18%.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##             main    #2277      +/-   ##
==========================================
+ Coverage   41.48%   41.66%   +0.18%     
==========================================
  Files         234      234              
  Lines       21987    22000      +13     
==========================================
+ Hits         9121     9166      +45     
+ Misses      12866    12834      -32     
Impacted Files Coverage Δ
boa_engine/src/syntax/lexer/regex.rs 53.16% <50.00%> (-0.36%) ⬇️
boa_engine/src/bytecompiler/mod.rs 29.20% <0.00%> (+0.43%) ⬆️
boa_engine/src/builtins/function/mod.rs 23.43% <0.00%> (+0.52%) ⬆️
boa_engine/src/vm/mod.rs 46.93% <0.00%> (+0.84%) ⬆️
boa_engine/src/value/conversions.rs 22.00% <0.00%> (+2.00%) ⬆️
boa_engine/src/syntax/lexer/template.rs 39.58% <0.00%> (+2.62%) ⬆️
boa_engine/src/builtins/object/mod.rs 56.55% <0.00%> (+3.37%) ⬆️
.../syntax/parser/expression/left_hand_side/member.rs 38.14% <0.00%> (+6.18%) ⬆️
...src/syntax/parser/expression/left_hand_side/mod.rs 54.54% <0.00%> (+9.09%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@raskad raskad added bug Something isn't working lexer Issues surrounding the lexer labels Sep 12, 2022
@raskad raskad added this to the v0.16.0 milestone Sep 12, 2022
@raskad
Copy link
Member

raskad commented Sep 12, 2022

VM implementation

Test result main count PR count difference
Total 91,733 91,733 0
Passed 64,940 64,942 +2
Ignored 16,580 16,580 0
Failed 10,213 10,211 -2
Panics 0 0 0
Conformance 70.79% 70.79% +0.00%
Fixed tests (2):
test/built-ins/RegExp/regexp-class-chars.js [strict mode] (previously Failed)
test/built-ins/RegExp/regexp-class-chars.js (previously Failed)

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.

Nice find. I think there is still a problem if an escaped ] is placed before the end of the character class right?
/[\]/]/ should be a valid regex but would not be lexed correctly with this approach.

@tunz
Copy link
Contributor Author

tunz commented Sep 12, 2022

@raskad Could you elaborate? I think there is no problem with /[\]/]/. The escaped ] should be handled by the backslash pattern match (line 81).

@raskad
Copy link
Member

raskad commented Sep 13, 2022

@raskad Could you elaborate? I think there is no problem with /[\]/]/. The escaped ] should be handled by the backslash pattern match (line 81).

True, the error I was looking at is unrelated and only happens in the boa_cli.

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.

Very nice fix, thank you!

Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

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

Good catch! Thanks for the fix :)

@Razican
Copy link
Member

Razican commented Sep 13, 2022

Bors r+

bors bot pushed a commit that referenced this pull request Sep 13, 2022
This PR fixes a case where a forward slash is located in a regex class: `let regex = /[/]/;`. In this case, the forward slash should not close the regex literal.

This fixes `test/built-ins/RegExp/regexp-class-chars.js`
@bors
Copy link

bors bot commented Sep 13, 2022

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Fix regex literal /[/]/ [Merged by Bors] - Fix regex literal /[/]/ Sep 13, 2022
@bors bors bot closed this Sep 13, 2022
@tunz tunz deleted the tunz/regex-literal-fix2 branch July 18, 2023 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lexer Issues surrounding the lexer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants