summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/matchers.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2023-07-08 13:42:13 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2023-07-08 13:42:13 -0600
commit66114cb155f2a975ecdc9f3d2d89a9df1142791a (patch)
tree627a5b52df731e62248bfe4ce0cb5ba5018394aa /modules/caddyhttp/matchers.go
parent7914ba3573fa8eeb05f193fffde1a1c1493e3d0b (diff)
caddyhttp: Trim dot/space only on Windows (fix #5613)
Follow-up to #2917. Path matcher needs to trim dots and spaces but only on Windows.
Diffstat (limited to 'modules/caddyhttp/matchers.go')
-rw-r--r--modules/caddyhttp/matchers.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/caddyhttp/matchers.go b/modules/caddyhttp/matchers.go
index f5f9a0f..fb84875 100644
--- a/modules/caddyhttp/matchers.go
+++ b/modules/caddyhttp/matchers.go
@@ -25,6 +25,7 @@ import (
"path"
"reflect"
"regexp"
+ "runtime"
"sort"
"strconv"
"strings"
@@ -395,7 +396,9 @@ func (m MatchPath) Match(r *http.Request) bool {
// security risk (cry) if PHP files end up being served
// as static files, exposing the source code, instead of
// being matched by *.php to be treated as PHP scripts.
- reqPath = strings.TrimRight(reqPath, ". ")
+ if runtime.GOOS == "windows" { // issue #5613
+ reqPath = strings.TrimRight(reqPath, ". ")
+ }
repl := r.Context().Value(caddy.ReplacerCtxKey).(*caddy.Replacer)