summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/matchers.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-12-17 10:14:04 -0700
committerMatthew Holt <mholt@users.noreply.github.com>2019-12-17 10:14:04 -0700
commitdae4913fe35ff3f8a97383061ea8d44c1e98279e (patch)
tree5d6cd9453b225fbdb3fc86d815d4d7560bca6ea5 /modules/caddyhttp/matchers.go
parent6455efa5d327377b41e708a063d1b7a71a131165 (diff)
http: Patch path matcher to ignore dots and spaces (#2917)
(Try saying "patch path match" ten times fast)
Diffstat (limited to 'modules/caddyhttp/matchers.go')
-rw-r--r--modules/caddyhttp/matchers.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/caddyhttp/matchers.go b/modules/caddyhttp/matchers.go
index eaa27f0..6d1728d 100644
--- a/modules/caddyhttp/matchers.go
+++ b/modules/caddyhttp/matchers.go
@@ -165,6 +165,14 @@ func (m MatchPath) Provision(_ caddy.Context) error {
// Match returns true if r matches m.
func (m MatchPath) Match(r *http.Request) bool {
lowerPath := strings.ToLower(r.URL.Path)
+
+ // see #2917; Windows ignores trailing dots and spaces
+ // when accessing files (sigh), potentially causing a
+ // 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
+ lowerPath = strings.TrimRight(lowerPath, ". ")
+
for _, matchPath := range m {
// special case: first character is equals sign,
// treat it as an exact match