-
Notifications
You must be signed in to change notification settings - Fork 586
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
strconv: Fix escaped backslashes \\ in braces ${} #125
Conversation
👍 |
@@ -70,6 +71,9 @@ func Unquote(s string) (t string, err error) { | |||
if q, _ := utf8.DecodeRuneInString(s); q == '"' { | |||
continue | |||
} | |||
if q, _ := utf8.DecodeRuneInString(s); q == '\\' { | |||
continue | |||
} |
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.
The performance is unlikely to matter but decoding utf8 runes is not exactly cheap, so perhaps we should just turn this into a switch
?
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.
Fair - I was just so punch drunk that the copy paste seemed too hilarious not to do 😄
Fixes hashicorp/terraform#6359 and several related issues by unescaping a double backslash within braces to a single backslash. This bumps into the bit of HIL that still hangs out in HCL - for values that aren't interpolated, like Terraform's variable defaults - users were unable to get a backslash to show up within `${}`. That's because `${}` is handled specially to allow for, e.g., double quotes inside of braces. Here, we add `\\` as a special cased escape (along with `\"`) so users can get backslashes in these scenarios by doubling them up.
Now, with more |
LGTM! |
Pulls in hashicorp/hcl#125 Which fixes #6359
Fixes hashicorp/terraform#6359 and several
related issues by unescaping a double backslash within braces to a
single backslash.
This bumps into the bit of HIL that still hangs out in HCL - for values
that aren't interpolated, like Terraform's variable defaults - users
were unable to get a backslash to show up within
${}
.That's because
${}
is handled specially to allow for, e.g., doublequotes inside of braces.
Here, we add
\\
as a special cased escape (along with\"
) so userscan get backslashes in these scenarios by doubling them up.