+
Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

fix(rome_js_syntax): Don't panic on unclosed block comment #2933

Merged
merged 2 commits into from
Jul 27, 2022

Conversation

MichaReiser
Copy link
Contributor

@MichaReiser MichaReiser commented Jul 26, 2022

This fixes an issue where Rome panicked when parsing suppression comments from a block comment without the closing */.

This PR gracefully handles the case where a block comment has no closing */ by trying to remove a trailing * or / at the end of the comment and otherwise take the comment as is.

Tests

I verified that running rome over rome classic no longer panics and added a unit test to the suppression comment parsing.

@MichaReiser MichaReiser requested review from a team, ematipico and leops July 26, 2022 15:15
@MichaReiser MichaReiser temporarily deployed to aws July 26, 2022 15:15 Inactive
This fixes an issue where Rome panicked when parsing suppression comments from a block comment without the closing `*/`.

This PR gracefully handles the case where a block comment has no closing `*/` by trying to remove a trailing `*` or `/` at the end of the comment and otherwise take the comment as is.

## Tests

I verified that running rome over rome classic no longer panics.

This is an analyzer specific issue. I'm not sure how to best write a test for this issue without adding it to a specific analyzer test. Please advice ;)
@github-actions
Copy link

github-actions bot commented Jul 26, 2022

@github-actions
Copy link

Parser conformance results on ubuntu-latest

js/262

Test result main count This PR count Difference
Total 45878 45878 0
Passed 44938 44938 0
Failed 940 940 0
Panics 0 0 0
Coverage 97.95% 97.95% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 39 39 0
Passed 36 36 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.31% 92.31% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 5946 5946 0
Passed 395 395 0
Failed 5551 5551 0
Panics 0 0 0
Coverage 6.64% 6.64% 0.00%

ts/babel

Test result main count This PR count Difference
Total 588 588 0
Passed 519 519 0
Failed 69 69 0
Panics 0 0 0
Coverage 88.27% 88.27% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 16257 16257 0
Passed 12393 12393 0
Failed 3864 3864 0
Panics 0 0 0
Coverage 76.23% 76.23% 0.00%

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jul 26, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: c59b30f
Status: ✅  Deploy successful!
Preview URL: https://05034877.tools-8rn.pages.dev
Branch Preview URL: https://fix-no-panic-on-unclosed-blo.tools-8rn.pages.dev

View logs

@leops
Copy link
Contributor

leops commented Jul 26, 2022

The tests for language-specific suppression comments are embedded directly in rome_js_analyze:

fn suppression() {

@MichaReiser MichaReiser force-pushed the fix/no-panic-on-unclosed-block branch from f357dfb to c59b30f Compare July 26, 2022 16:03
@MichaReiser MichaReiser temporarily deployed to aws July 26, 2022 16:03 Inactive
@leops leops merged commit 41e2f63 into main Jul 27, 2022
@leops leops deleted the fix/no-panic-on-unclosed-block branch July 27, 2022 08:09
IWANABETHATGUY pushed a commit to IWANABETHATGUY/tools that referenced this pull request Aug 22, 2022
* fix(rome_js_syntax): Don't panic on unclosed block comment

This fixes an issue where Rome panicked when parsing suppression comments from a block comment without the closing `*/`.

This PR gracefully handles the case where a block comment has no closing `*/` by trying to remove a trailing `*` or `/` at the end of the comment and otherwise take the comment as is.

## Tests

I verified that running rome over rome classic no longer panics.

This is an analyzer specific issue. I'm not sure how to best write a test for this issue without adding it to a specific analyzer test. Please advice ;)

* add unit test
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载