Repository navigation
caddyhttp: keep absent optional placeholders empty - #8019
Conversation
|
Hi @steadytao I was wondering if default value support in placeholders (#7967) could be a solution that makes everyone happy. Let me (try to) explain my thought: |
|
Hmmmm. Defaults could be fairly useful separately but this fixes existing configurations without requiring users to change their placeholders. #7967 only applies a default when the underlying name is recognised so it would still need this fix for valid TLS placeholders on plain HTTP. |
|
Happy to deliberate though. |
|
Does need merge before .5 ^ |
Preserving existing configurations is much appreciated.
I see. A potential use case for other placeholders beside tls and cookie are http request headers that are passed via placeholders to backends (maybe even in |
|
That case should already work as |
|
Not a bad shout. Yes please. |
|
pushed a regression test for this to #8008 just now covering both absent and present header placeholders, all clean! |
|
@steadytao needed for 2.11.7 |
Since caddyserver#8019 a missing cookie placeholder returned an empty string, so CEL expressions such as `{cookie.foo} != null` matched every request. Return nil (still known) so CEL sees null again, while string replacement keeps writing an empty value. Fixes caddyserver#8481
Summary
Keep missing cookie and valid TLS placeholders empty when using
ReplaceKnown. Unknown or malformed TLS placeholder names remain literal, and existing TLS values are unchanged.Follow-up to #8014, prompted by @steffenbusch’s compatibility concern in #8013 (thankyou)
Added coverage for absent and present cookies, valid TLS placeholders on plain HTTP, invalid TLS names and static-response headers.
Assistance Disclosure
Claude was used to help trace the compatibility failure mentioned by Steffen which was then verified and the PR was authored by hand.