Skip to content

[CS2] Quotation mark characters are escaped unnecessarily in template literals #4589

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

Closed
Inve1951 opened this issue Jun 25, 2017 · 6 comments
Closed

Comments

@Inve1951
Copy link
Contributor

Inve1951 commented Jun 25, 2017

"""<div id="unique" onclick="update('#{someVar}')"></div>"""

compiles to

`<div id=\"unique\" onclick=\"update('${someVar}')\"></div>`;

\" doesn't need escaping

@GeoffreyBooth GeoffreyBooth changed the title [v2] string interpolation misbeahavior [CS2] Escaping in interpolated strings Jun 25, 2017
@GeoffreyBooth
Copy link
Collaborator

GeoffreyBooth commented Jun 25, 2017

Agreed that the "s don’t need to be escaped in the second example, but what’s wrong with the first? #{ isn’t supposed to interpolate in '-delimited strings.

Also, \" is harmless. It just becomes ", as if it hadn’t been escaped. So the current output works, it’s just not optimal.

@Inve1951
Copy link
Contributor Author

#{ isn’t supposed to interpolate in '-delimited strings.

it's not? i thought ' and " are interchangeable

@GeoffreyBooth
Copy link
Collaborator

i thought ' and " are interchangeable

Nope: http://coffeescript.org/v2/#strings. It’s always been that way, that’s not a v2 thing. CoffeeScript is mimicking Ruby and Bash (among others) in this regard.

@Inve1951
Copy link
Contributor Author

i see. want to close and open a new issue or leave it?

@GeoffreyBooth GeoffreyBooth changed the title [CS2] Escaping in interpolated strings [CS2] Quotation mark characters are escaped unnecessarily in template literals Jun 26, 2017
@GeoffreyBooth
Copy link
Collaborator

Up to you. Maybe just edit your first post?

GeoffreyBooth added a commit to GeoffreyBooth/coffeescript that referenced this issue Aug 24, 2017
…es, so that quotation marks are not unnecessarily escaped in backtick-delimited strings/template literals
GeoffreyBooth added a commit that referenced this issue Aug 27, 2017
…at quotation marks are not unnecessarily escaped in backtick-delimited strings/template literals (#4660)
@GeoffreyBooth
Copy link
Collaborator

Fixed by #4660.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants