aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/hashicorp/hcl
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/hcl')
-rw-r--r--vendor/github.com/hashicorp/hcl/decoder.go14
-rw-r--r--vendor/github.com/hashicorp/hcl/hcl/parser/parser.go5
-rw-r--r--vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go8
-rw-r--r--vendor/github.com/hashicorp/hcl/hcl/strconv/quote.go19
4 files changed, 30 insertions, 16 deletions
diff --git a/vendor/github.com/hashicorp/hcl/decoder.go b/vendor/github.com/hashicorp/hcl/decoder.go
index c8a077d..0b39c1b 100644
--- a/vendor/github.com/hashicorp/hcl/decoder.go
+++ b/vendor/github.com/hashicorp/hcl/decoder.go
@@ -91,7 +91,7 @@ func (d *decoder) decode(name string, node ast.Node, result reflect.Value) error
return d.decodeBool(name, node, result)
case reflect.Float64:
return d.decodeFloat(name, node, result)
- case reflect.Int:
+ case reflect.Int, reflect.Int32, reflect.Int64:
return d.decodeInt(name, node, result)
case reflect.Interface:
// When we see an interface, we make our own thing
@@ -164,7 +164,11 @@ func (d *decoder) decodeInt(name string, node ast.Node, result reflect.Value) er
return err
}
- result.Set(reflect.ValueOf(int(v)))
+ if result.Kind() == reflect.Interface {
+ result.Set(reflect.ValueOf(int(v)))
+ } else {
+ result.SetInt(v)
+ }
return nil
case token.STRING:
v, err := strconv.ParseInt(n.Token.Value().(string), 0, 0)
@@ -172,7 +176,11 @@ func (d *decoder) decodeInt(name string, node ast.Node, result reflect.Value) er
return err
}
- result.Set(reflect.ValueOf(int(v)))
+ if result.Kind() == reflect.Interface {
+ result.Set(reflect.ValueOf(int(v)))
+ } else {
+ result.SetInt(v)
+ }
return nil
}
}
diff --git a/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go b/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go
index 54a6493..476ed04 100644
--- a/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go
+++ b/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go
@@ -256,7 +256,10 @@ func (p *Parser) objectKey() ([]*ast.ObjectKey, error) {
keyCount++
keys = append(keys, &ast.ObjectKey{Token: p.tok})
case token.ILLEGAL:
- fmt.Println("illegal")
+ return keys, &PosError{
+ Pos: p.tok.Pos,
+ Err: fmt.Errorf("illegal character"),
+ }
default:
return keys, &PosError{
Pos: p.tok.Pos,
diff --git a/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go b/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go
index 0735d95..6966236 100644
--- a/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go
+++ b/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go
@@ -95,6 +95,12 @@ func (s *Scanner) next() rune {
s.srcPos.Column = 0
}
+ // If we see a null character with data left, then that is an error
+ if ch == '\x00' && s.buf.Len() > 0 {
+ s.err("unexpected null character (0x00)")
+ return eof
+ }
+
// debug
// fmt.Printf("ch: %q, offset:column: %d:%d\n", ch, s.srcPos.Offset, s.srcPos.Column)
return ch
@@ -474,7 +480,7 @@ func (s *Scanner) scanString() {
// read character after quote
ch := s.next()
- if ch < 0 || ch == eof {
+ if (ch == '\n' && braces == 0) || ch < 0 || ch == eof {
s.err("literal not terminated")
return
}
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