From 96d6d277a453a602b9ec49131d8e332ce7aefcad Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Tue, 5 May 2020 14:32:12 -0400 Subject: 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 --- caddyconfig/caddyfile/formatter_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'caddyconfig/caddyfile/formatter_test.go') diff --git a/caddyconfig/caddyfile/formatter_test.go b/caddyconfig/caddyfile/formatter_test.go index 25bd7fa..6751eca 100644 --- a/caddyconfig/caddyfile/formatter_test.go +++ b/caddyconfig/caddyfile/formatter_test.go @@ -201,7 +201,7 @@ c } d { - e #f + e#f # g } @@ -229,7 +229,7 @@ bar" j { "\"k\" l m" }`, - expect: `"a \"b\" " #c + expect: `"a \"b\" "#c d e { @@ -305,6 +305,11 @@ bar "{\"key\":34}"`, baz`, }, + { + description: "hash within string is not a comment", + input: `redir / /some/#/path`, + expect: `redir / /some/#/path`, + }, } { // the formatter should output a trailing newline, // even if the tests aren't written to expect that -- cgit v1.2.3