Repository navigation
caddyhttp: preserve unknown placeholders in static response headers - #8014
Merged
steadytao merged 1 commit intoSep 13, 2026
Merged
Conversation
The respond directive expanded header field names and values with
repl.ReplaceAll, which blanks any {...} the replacer does not recognize
Header values are config data, often JSON or carrying literal braces, so a
value like {key:value} was sent empty and a-{b}-c came out a--c
Use ReplaceKnown, matching the header handler fix in caddyserver#4880 (same class as
caddyserver#4418) and the respond body expansion a few lines below, so unknown braces
survive and real placeholders still expand
steadytao
pushed a commit
that referenced
this pull request
Sep 26, 2026
…8017) The basic auth provider expanded account usernames and passwords with repl.ReplaceAll, which blanks any {...} the replacer does not recognize Credentials are config data, so a username like alice-{bogus} was stored as alice- and a password like ab{cd}ef was quietly rewritten into different valid base64, turning a config mistake into a working password the admin never set Use ReplaceKnown, matching the respond headers fix in #8014 and the header handler fix in #4880, so unknown braces survive and real placeholders like {env.*} still expand
This was referenced Sep 30, 2026
Contributor
Author
|
Thanks for the review and merge @steadytao, glad this fix is in now, cheers! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #8013
Summary
the respond directive expanded header field names and values with
repl.ReplaceAll, which blanks any{...}the replacer does not recognize, so a JSON header value like{"key":"value"}was sent empty andvalue-{unknown}-keptcame outvalue--keptthis switches both to
repl.ReplaceKnown, matching the header handler fix in #4880 (same class as #4418) and therespondbody expansion a few lines below, so unrecognized braces are left intact and real placeholders still expandSteps to reproduce
go test ./modules/caddyhttp/ -run TestStaticResponseHeadersKeepUnknownPlaceholders -count=1{...}survive, real placeholders still expandregression tests in
staticresp_test.gopin both directions: unknown braces survive and a set placeholder still expandsAssistance Disclosure
AI used: yes, for drafting test coverage and description formatting