config/lang: escaping interpolations with double dollar signs
This commit is contained in:
parent
c15c17dfe9
commit
c05d7a6acd
|
@ -299,11 +299,21 @@ func (x *parserLex) lexString(yylval *parserSymType, quoted bool) (int, bool) {
|
|||
|
||||
// If we hit a dollar sign, then check if we're starting
|
||||
// another interpolation. If so, then we're done.
|
||||
if c == '$' && x.peek() == '{' {
|
||||
if c == '$' {
|
||||
n := x.peek()
|
||||
|
||||
// If it is '{', then we're starting another interpolation
|
||||
if n == '{' {
|
||||
x.backup()
|
||||
break
|
||||
}
|
||||
|
||||
// If it is '$', then we're escaping a dollar sign
|
||||
if n == '$' {
|
||||
x.next()
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := b.WriteRune(c); err != nil {
|
||||
x.Error(err.Error())
|
||||
return lexEOF, false
|
||||
|
|
|
@ -25,6 +25,16 @@ func TestLex(t *testing.T) {
|
|||
[]int{STRING, PROGRAM_BRACKET_LEFT, IDENTIFIER, PROGRAM_BRACKET_RIGHT, lexEOF},
|
||||
},
|
||||
|
||||
{
|
||||
"foo $${bar}",
|
||||
[]int{STRING, lexEOF},
|
||||
},
|
||||
|
||||
{
|
||||
"foo $$$${bar}",
|
||||
[]int{STRING, lexEOF},
|
||||
},
|
||||
|
||||
{
|
||||
"foo ${\"bar\"}",
|
||||
[]int{STRING, PROGRAM_BRACKET_LEFT, STRING, PROGRAM_BRACKET_RIGHT, lexEOF},
|
||||
|
|
Loading…
Reference in New Issue