diff --git a/CHANGELOG.md b/CHANGELOG.md index 89b8286..aef952e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Removed ### Fixed +- Do not treat $ as escape char in plain strings/regexes #120 ## [0.6.3] diff --git a/variables.go b/variables.go index 2bcf875..3a76d21 100644 --- a/variables.go +++ b/variables.go @@ -429,9 +429,11 @@ func lexer(in string) (<-chan token, <-chan error) { lex <- openToken off++ varcount++ - default: // escape any symbol + case '$', '}': // escape $} and $$ content = content[:idx] + content[off:] continue + default: + continue } } diff --git a/variables_test.go b/variables_test.go index 4a1fba8..270f7dd 100644 --- a/variables_test.go +++ b/variables_test.go @@ -42,6 +42,7 @@ func TestVarExpParserSuccess(t *testing.T) { {"plain string", "string", str("string")}, {"string containing :", "just:a:string", str("just:a:string")}, {"string containing }", "abc } def", str("abc } def")}, + {"string containging regex with $", "log$|leg$", str("log$|leg$")}, {"string with escaped var", "escaped $${var}", str("escaped ${var}")}, {"reference", "${reference}", ref("reference")}, {"exp in middle", "test ${splice} this",