Skip to content
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

Do not treat $ as escape char in plain strings/regexes #120

Merged
merged 4 commits into from
Oct 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
4 changes: 3 additions & 1 deletion variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
1 change: 1 addition & 0 deletions variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down