aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/hashicorp/hcl/hcl/strconv/quote.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/hcl/hcl/strconv/quote.go')
-rw-r--r--vendor/github.com/hashicorp/hcl/hcl/strconv/quote.go19
1 files changed, 8 insertions, 11 deletions
diff --git a/vendor/github.com/hashicorp/hcl/hcl/strconv/quote.go b/vendor/github.com/hashicorp/hcl/hcl/strconv/quote.go
index 956c899..5f981ea 100644
--- a/vendor/github.com/hashicorp/hcl/hcl/strconv/quote.go
+++ b/vendor/github.com/hashicorp/hcl/hcl/strconv/quote.go
@@ -27,6 +27,9 @@ func Unquote(s string) (t string, err error) {
if quote != '"' {
return "", ErrSyntax
}
+ if !contains(s, '$') && !contains(s, '{') && contains(s, '\n') {
+ return "", ErrSyntax
+ }
// Is it trivial? Avoid allocation.
if !contains(s, '\\') && !contains(s, quote) && !contains(s, '$') {
@@ -46,7 +49,7 @@ func Unquote(s string) (t string, err error) {
for len(s) > 0 {
// If we're starting a '${}' then let it through un-unquoted.
// Specifically: we don't unquote any characters within the `${}`
- // section, except for escaped backslashes, which we handle specifically.
+ // section.
if s[0] == '$' && len(s) > 1 && s[1] == '{' {
buf = append(buf, '$', '{')
s = s[2:]
@@ -61,16 +64,6 @@ func Unquote(s string) (t string, err error) {
s = s[size:]
- // We special case escaped backslashes in interpolations, converting
- // them to their unescaped equivalents.
- if r == '\\' {
- q, _ := utf8.DecodeRuneInString(s)
- switch q {
- case '\\':
- continue
- }
- }
-
n := utf8.EncodeRune(runeTmp[:], r)
buf = append(buf, runeTmp[:n]...)
@@ -94,6 +87,10 @@ func Unquote(s string) (t string, err error) {
}
}
+ if s[0] == '\n' {
+ return "", ErrSyntax
+ }
+
c, multibyte, ss, err := unquoteChar(s, quote)
if err != nil {
return "", err