Skip to content

When pasting an unknown string into a string, if we decide to escape any characters, make sure we escape all characters#62982

Merged
CyrusNajmabadi merged 1 commit intodotnet:mainfrom
CyrusNajmabadi:stringCopyPasteEscaping
Jul 27, 2022
Merged

When pasting an unknown string into a string, if we decide to escape any characters, make sure we escape all characters#62982
CyrusNajmabadi merged 1 commit intodotnet:mainfrom
CyrusNajmabadi:stringCopyPasteEscaping

Conversation

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi commented Jul 27, 2022

Fixes #62969

The general issue here is that when text is being pasted in from an unknown source, we don't know what an escaped chunk like "" should mean. Should we escape the text again within the destination? or should we say that because it's a legal escape in teh destination taht we'll leave it alone? Previously we had the logic that we would leave it alone. However, this isn't great when you have a mix of quotes. e.g.

This is the text on the clipboard: [SuppressMessage("", "CA2013")]

Here, we'll need to escape the quotes in "CA2013" to make the destination legal. But if we're going to escape those, then we should realize that we should also escape "" to """" (even though we technically don't have to). But escaping inconsistently is far worse as it basically means we're treating different parts of the pasted text differently instead of uniformly.

…any characters, make sure we escape all characters
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner July 27, 2022 18:06
@ghost ghost added the Area-IDE label Jul 27, 2022
@Youssef1313
Copy link
Copy Markdown
Member

Nice! Thanks @CyrusNajmabadi for the quick fix!

@CyrusNajmabadi CyrusNajmabadi enabled auto-merge July 27, 2022 18:47
@CyrusNajmabadi CyrusNajmabadi merged commit e3a9a6c into dotnet:main Jul 27, 2022
@ghost ghost added this to the Next milestone Jul 27, 2022
@CyrusNajmabadi CyrusNajmabadi deleted the stringCopyPasteEscaping branch July 27, 2022 22:19
@dibarbet dibarbet modified the milestones: Next, 17.4 P2 Sep 1, 2022
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 this pull request may close these issues.

Pasting in verbatim string doesn't properly escape double quotes

4 participants