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

Style/QuotedSymbols endless loop caused by escaped quote character #10148

Closed
joshua-v-jones opened this issue Sep 30, 2021 · 1 comment · Fixed by #10152
Closed

Style/QuotedSymbols endless loop caused by escaped quote character #10148

joshua-v-jones opened this issue Sep 30, 2021 · 1 comment · Fixed by #10152
Labels

Comments

@joshua-v-jones
Copy link

joshua-v-jones commented Sep 30, 2021

On upgrading rubocop from version 1.1.0 to 1.22.0 there was a problem running the auto-correct command. The issue causes a file to be continuously filled with '/'s.

Expected behavior

Normally, rubocop would replace the double ticks with single ticks in this statement:

:"Le produit avec le SKU \"%1\" n’existe pas"

Would be replaced with
:'Le produit avec le SKU \"%1\" n’existe pas'

Actual behavior

Rubocop gets caught in an endless loop continuously generating '/'s like below:

:"Le produit avec le SKU \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"%1\" n’existe pas"

The file with this line is never corrected and CLI does not progress.

Steps to reproduce the problem

Create a ruby file with the line above.

Run rubocop -a

The command line will hang and when forced to exit the file should contain many '/'s.

RuboCop version

1.22.0
no output possible as the code hangs on an endless loop.

@joshua-v-jones joshua-v-jones changed the title Endless loop generating slashes in a file Endless loop generating slashes in a file to correct 1.22.0 Sep 30, 2021
@dvandersluis
Copy link
Member

dvandersluis commented Sep 30, 2021

I can replicate this, looking into it now.

@dvandersluis dvandersluis changed the title Endless loop generating slashes in a file to correct 1.22.0 Style/QuotedSymbols Endless loop generating slashes in a file to correct 1.22.0 Sep 30, 2021
@dvandersluis dvandersluis changed the title Style/QuotedSymbols Endless loop generating slashes in a file to correct 1.22.0 Style/QuotedSymbols endless loop caused by escaped quote character Sep 30, 2021
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Oct 1, 2021
…ters incorrectly.

Two cases are improved here:
1. Escaped double quotes (`\"`) within a double-quoted string are handled correctly (replaced with an unescaped double quote) when converting to a single-quoted string.
2. Escaped backslashes (`\\`) are treated properly and not doubled for both single- and double-quoted strings.
bbatsov pushed a commit that referenced this issue Oct 2, 2021
…correctly.

Two cases are improved here:
1. Escaped double quotes (`\"`) within a double-quoted string are handled correctly (replaced with an unescaped double quote) when converting to a single-quoted string.
2. Escaped backslashes (`\\`) are treated properly and not doubled for both single- and double-quoted strings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants