Skip to content

caddytls: keep repeated matchers in nested matcher sets - #8137

Merged
francislavoie merged 1 commit into
caddyserver:masterfrom
simonether:tls-nested-matcher-repeats
Oct 4, 2026
Merged

francislavoie merged 1 commit into
caddyserver:masterfrom
simonether:tls-nested-matcher-repeats

Conversation

@simonether

Copy link
Copy Markdown
Contributor

caddytls.ParseCaddyfileNestedMatcherSet groups the tokens of a repeated matcher, then hands them to caddyfile.UnmarshalModule, which reads only the first segment. So this block

match {
	sni example.com
	sni example.net
}

gives {"sni":["example.com"]}, and the second line is ignored without an error. A remote_ip !10.1.2.3 exclusion on its own line is lost the same way.

This passes all the tokens to UnmarshalCaddyfile, like caddyhttp.ParseCaddyfileNestedMatcherSet does. The TLS matchers are written to handle several segments. A repeated sni_regexp now returns its existing "regular expression can only be used once" error instead of dropping the second pattern.

It came up while working on #8097. I kept it out of the not matcher PR, as asked there.

Assistance Disclosure

Claude Code (claude-opus-5-5) found this while testing the not matcher, wrote the fix, I tested it. I reviewed every line

ParseCaddyfileNestedMatcherSet collected the tokens of a repeated
matcher but passed them to caddyfile.UnmarshalModule, which reads only
the first segment, so a second sni or remote_ip line in a match block
was silently dropped. Pass all tokens to UnmarshalCaddyfile, like the
caddyhttp version does.
@CLAassistant

CLAassistant commented Oct 4, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@francislavoie francislavoie added the bug 🐞 Something isn't working label Oct 4, 2026
@francislavoie francislavoie added this to the v2.12.0 milestone Oct 4, 2026
@francislavoie
francislavoie enabled auto-merge (squash) October 4, 2026 16:07
@francislavoie
francislavoie merged commit 1706dc8 into caddyserver:master Oct 4, 2026
27 checks passed
This was referenced Nov 3, 2026
NickCao pushed a commit to NickCao/caddy that referenced this pull request Nov 4, 2026
@francislavoie francislavoie modified the milestones: v2.12.0, v2.11.8 Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐞 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants