summaryrefslogtreecommitdiff
path: root/caddyconfig
diff options
context:
space:
mode:
authorMatt Holt <mholt@users.noreply.github.com>2019-10-15 16:05:53 -0600
committerGitHub <noreply@github.com>2019-10-15 16:05:53 -0600
commit2f91b44587fe487b6a05c1c7e56833247e4b8c79 (patch)
treebcee95d5d6e805b4ff0ff81df9916f8689f1c85e /caddyconfig
parente3726588b416682db28ea9173bf2c36e4554ce05 (diff)
v2: Make tests work on Windows (#2782)
* file_server: Make tests work on Windows * caddyfile: Fix escaping when character is not escapable We only escape certain characters depending on inside or outside of quotes (mainly newlines and quotes). We don't want everyone to have to escape Windows file paths like C:\\Windows\\... but we can't drop the \ either if it's just C:\Windows\...
Diffstat (limited to 'caddyconfig')
-rwxr-xr-xcaddyconfig/caddyfile/lexer.go5
-rwxr-xr-xcaddyconfig/caddyfile/lexer_test.go6
2 files changed, 11 insertions, 0 deletions
diff --git a/caddyconfig/caddyfile/lexer.go b/caddyconfig/caddyfile/lexer.go
index 0ddad0e..687ff90 100755
--- a/caddyconfig/caddyfile/lexer.go
+++ b/caddyconfig/caddyfile/lexer.go
@@ -153,6 +153,11 @@ func (l *lexer) next() bool {
}
}
+ if escaped {
+ val = append(val, '\\')
+ escaped = false
+ }
+
val = append(val, ch)
}
}
diff --git a/caddyconfig/caddyfile/lexer_test.go b/caddyconfig/caddyfile/lexer_test.go
index ce2e147..9105eb5 100755
--- a/caddyconfig/caddyfile/lexer_test.go
+++ b/caddyconfig/caddyfile/lexer_test.go
@@ -152,6 +152,12 @@ func TestLexer(t *testing.T) {
},
},
{
+ input: `un\escapable`,
+ expected: []Token{
+ {Line: 1, Text: `un\escapable`},
+ },
+ },
+ {
input: `A "quoted value with line
break inside" {
foobar