-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
fix #22926, raw string escaping rules that allow writing all strings #24621
Conversation
bddb358
to
2028ae8
Compare
NEWS.md
Outdated
@@ -130,6 +130,10 @@ Language changes | |||
* Like `_`, variable names consisting only of underscores can be assigned, | |||
but accessing their values is deprecated ([#24221]). | |||
|
|||
* Raw string literal escaping rules have been changed to make it possible to write all strings. | |||
The rule is that backslashes escape both quotes and other backslashes, but only when appearing | |||
directly before a quote character ([#22926]). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"but only when a sequence of backslashes precedes a quote character. Thus, 2n
backslashes followed by a quote encodes n
backslashes and the end of the literal while 2n+1
backslashes followed by a quote encodes n
backslashes followed by a quote character."
base/strings/io.jl
Outdated
The exception is that quotation marks still must be escaped. | ||
The exception is that quotation marks still must be escaped. Backslashes | ||
escape both question marks and other backslashes, but only when immediately | ||
preceding a quote character. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
Looks like there's a couple other tests to fix though too: Lines 742 to 745 in 2028ae8
|
2028ae8
to
5b0ae07
Compare
base/strings/io.jl
Outdated
@@ -371,15 +371,25 @@ macro b_str(s); :(Vector{UInt8}($(unescape_string(s)))); end | |||
@raw_str -> String | |||
|
|||
Create a raw string without interpolation and unescaping. | |||
The exception is that quotation marks still must be escaped. | |||
The exception is that quotation marks still must be escaped. Backslashes | |||
escape both question marks and other backslashes, but only when a sequence |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"question" -> "quotation" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
5b0ae07
to
f356869
Compare
I implemented @vtjnash 's proposal since that seemed to be the most popular.