Repository navigation
requestbody: replace only known placeholders in the set body - #8008
Merged
steadytao merged 1 commit intoSep 26, 2026
Merged
Conversation
This was referenced Sep 13, 2026
The set body is user-supplied and commonly JSON, but it was expanded with
ReplaceAll, which blanks any {...} the replacer does not recognize, so a
plain JSON body was sent empty and a body mixing JSON with a real
placeholder was mangled
Use ReplaceKnown, matching the respond body, so unrecognized braces are
left intact and real placeholders still expand. Regression test pins both
directions
hktitof
force-pushed
the
fix/requestbody-set-known-placeholders
branch
from
September 14, 2026 12:02
5c96725 to
27e2e17
Compare
Contributor
Author
|
all checks green on the head, ready whenever you have time @steadytao! |
Contributor
Author
|
thanks for the review and merge @steadytao, happy to contribute to caddy! |
This was referenced Sep 30, 2026
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.
Summary
the request_body
setbody is user-supplied and commonly JSON, but it was expanded withrepl.ReplaceAll, which blanks any{...}the replacer does not recognize, so a plain JSON body was sent emptya body that does use a placeholder is mangled too:
{"token":"{env.SOME_VAR}"}came out as"}, since the opening{"token":"is consumed as an unrecognized placeholder before the real one is reachedthis switches the set body to
repl.ReplaceKnown, matching therespondbody and the active health check body (#8003), so unrecognized braces are left intact and real placeholders still expandregression tests in
requestbody_test.gopin both directions: JSON braces survive, a known placeholder still expandsreported for the JSON case in #7021
Assistance Disclosure
AI used: yes, for drafting test coverage and description formatting