diff options
author | Francis Lavoie <lavofr@gmail.com> | 2020-05-05 14:32:12 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-05 12:32:12 -0600 |
commit | 96d6d277a453a602b9ec49131d8e332ce7aefcad (patch) | |
tree | 6e34311edcc3c82b7c9436d145a122fba7b65258 /caddyconfig/caddyfile/lexer_test.go | |
parent | 26e559662d677062874afed9775f660f1f5f9c1e (diff) |
caddyconfig: Don't start comments in middle of tokens (#3267)
* caddyconfig: Only parse # as start of comment if preceded by space
* caddyconfig: Simplify # logic using len(val), add a test
Diffstat (limited to 'caddyconfig/caddyfile/lexer_test.go')
-rwxr-xr-x | caddyconfig/caddyfile/lexer_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/caddyconfig/caddyfile/lexer_test.go b/caddyconfig/caddyfile/lexer_test.go index 734006e..c8c941a 100755 --- a/caddyconfig/caddyfile/lexer_test.go +++ b/caddyconfig/caddyfile/lexer_test.go @@ -78,6 +78,26 @@ func TestLexer(t *testing.T) { }, }, { + input: `host:123 { + # hash inside string is not a comment + redir / /some/#/path + }`, + expected: []Token{ + {Line: 1, Text: "host:123"}, + {Line: 1, Text: "{"}, + {Line: 3, Text: "redir"}, + {Line: 3, Text: "/"}, + {Line: 3, Text: "/some/#/path"}, + {Line: 4, Text: "}"}, + }, + }, + { + input: "# comment at beginning of file\n# comment at beginning of line\nhost:123", + expected: []Token{ + {Line: 3, Text: "host:123"}, + }, + }, + { input: `a "quoted value" b foobar`, expected: []Token{ |