Repository navigation
caddyfile: avoid quadratic heredoc marker scanning - #8203
Merged
Merged
Conversation
zhaikong
pushed a commit
to zhaikong/caddy
that referenced
this pull request
Oct 15, 2026
zhaikong
pushed a commit
to zhaikong/caddy
that referenced
this pull request
Oct 31, 2026
zhaikong
pushed a commit
to zhaikong/caddy
that referenced
this pull request
Oct 31, 2026
This was referenced Nov 3, 2026
NickCao
pushed a commit
to NickCao/caddy
that referenced
this pull request
Nov 4, 2026
(cherry picked from commit 7328273)
zhaikong
pushed a commit
to zhaikong/caddy
that referenced
this pull request
Nov 10, 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.
Long heredoc markers made tokenization repeatedly convert and compare the entire marker-sized suffix after every body rune. A captured 501 KB fuzz testcase exceeded a five-second timeout; it now returns an incomplete-heredoc error in approximately 15 ms.
Use incremental KMP matching to scan the body in linear time while preserving existing marker semantics. Add regression coverage for long markers, overlapping prefixes, Unicode and invalid UTF-8 bodies, incomplete heredocs, and raw-source preservation, plus a benchmark. The costly comparison predates #7880.
Validation:
go test -race -short -timeout 120s ./...passed with local socket access.go build -buildvcs=false ./...passed.golangci-lint run --timeout 10mpassed with zero issues.FuzzFormatSemanticPreserverun passed 28,139 executions.AI assistance: OpenAI Codex (GPT-6) generated and tested this change.