fix: allow regex metacharacters in arguments#76
Open
tomholford wants to merge 1 commit intocaddyserver:masterfrom
Open
fix: allow regex metacharacters in arguments#76tomholford wants to merge 1 commit intocaddyserver:masterfrom
tomholford wants to merge 1 commit intocaddyserver:masterfrom
Conversation
The `argument` token's regex only allowed `[a-zA-Z\-_+.\\\/*:$0-9@]`, so
`path_regexp`-style matchers containing `(`, `)`, `[`, `]`, `|`, `?`, or
`^` produced an ERROR node that swallowed everything after the first
metacharacter.
Example from a real Caddyfile:
@broken path_regexp /foo/(bar|baz).*
@also-broken path_regexp /foo/[0-9]+
Widen the unquoted-argument char classes to include `()[]|?^` so regex
arguments lex as a single token and parse cleanly.
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
argumenttoken's regex only allowed[a-zA-Z\-_+.\\\/*:$0-9@], sopath_regexp-style matchers containing(,),[,],|,?, or^produced anERRORnode that swallowed everything after the first metacharacter — breaking both parsing and downstream syntax highlighting for the rest of the file.Repro:
Before this change the whole file after
@brokenfalls into anERRORnode.Fix
Widen the unquoted-argument character classes to include
()[]|?^so regex arguments lex as a singleargumenttoken and the rest of the file parses cleanly.=was intentionally left out to preservestatus_code_fallback(=404) precedence.Test plan
path_regexp with Regexcorpus case intest/corpus/named_matchers.txttree-sitter test— 43/43 passing (was 42 before)Status Code Fallbacktest still passesexamples/*.caddyfilestill parse without new errorsContext
Originally surfaced via a downstream Zed extension bug report: nusnewob/caddyfile-zed#7