rewrite: escape file matcher paths before rewriting#7683
rewrite: escape file matcher paths before rewriting#7683cyphercodes wants to merge 4 commits intocaddyserver:masterfrom
Conversation
Preserve matched file paths containing literal '?' or '%' when try_files rewrites to http.matchers.file.relative.
|
Pushed a follow-up to cover the multiple-depth case: the try_files rewrite test now includes an escaped filename under a nested path and creates parent directories for table cases. Local verification:
|
|
I meant a test that covers a request with %2F in the filename not conflicting with nesting. Also you need to sign the CLA, your commits authored by AI will probably need to be rewritten. |
|
Pushed a follow-up for the Local verification:
|
|
We can't accept the changes without the CLA being signed. |
|
@cyphercodes You must clean and rebase this branch as your AI Agent |
ef8e9f6 to
4563a2e
Compare
|
Rewrote the branch metadata so all three commits are authored/committed as No source changes were made in this rewrite; it only replaces the previous |
| fileMatchRelativePlaceholder := "{http.matchers.file.relative}" | ||
| if strings.Contains(path, fileMatchRelativePlaceholder) { | ||
| if val, ok := repl.Get("http.matchers.file.relative"); ok { | ||
| path = strings.ReplaceAll(path, fileMatchRelativePlaceholder, escapePathPreservingSlashes(fmt.Sprint(val))) |
There was a problem hiding this comment.
I think fmt.Sprint is being used because val is type any, but that's not the right way to do it. The type should be asserted to be string explicitly, not just fed into fmt.Sprint.
|
Pushed a follow-up for the latest review: Local verification:
|
Summary
?and%whentry_filesrewrites to{http.matchers.file.relative}.Fixes #7678
Tests
go test ./modules/caddyhttp/fileserver -run TestTryFilesRewriteEscapesMatchedPath -count=1go test ./modules/caddyhttp/rewrite ./modules/caddyhttp/fileserver -count=1Assistance Disclosure
AI assistance was used for investigation, implementation, and tests. I used Hermes Agent (OpenAI GPT-5.5) and verified the generated changes with the tests above.