@marcel91200 / caddy Mirror · read-only / commits / 4fce7c8b
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 11, 03:30 UTC

caddyhttp: document CEL raw strings for regexp patterns (#8280)

Co-authored-by: hikmetba-bit <hikmetba-bit@users.noreply.github.com>

Francis Lavoie committed Oct 29, 2026 at 09:08 UTC 4fce7c8bbcf260f1dfdc10f9f7d4d1ca76885a24
1 file changed +16
modules/caddyhttp/matchers.go
+16
@@ -843,6 +843,13 @@ func (m MatchPathRE) MatchWithError(r *http.Request) (bool, error) {
843 // Example:
844 //
845 // expression path_regexp('^/bar')
846 +//
847 +// The pattern is a CEL string literal, so CEL's own escape sequences
848 +// (e.g. \b, \n, \t) are interpreted before the result reaches the regexp
849 +// engine. A pattern that needs a literal backslash escape meant for the
850 +// regexp engine, such as \b for a word boundary, should be written as a
851 +// CEL raw string (prefixed with r) so CEL passes the backslash through
852 +// unchanged: expression path_regexp(r'^/bar\b').
853 func (MatchPathRE) CELLibrary(ctx caddy.Context) (cel.Library, error) {
854 unnamedPattern, err := CELMatcherImpl(
855 "path_regexp",
@@ -1309,6 +1316,15 @@ func (m MatchHeaderRE) Validate() error {
1316 // Example:
1317 //
1318 // expression header_regexp('foo', 'Field', 'fo+')
1319 +//
1320 +// The pattern is a CEL string literal, so CEL's own escape sequences
1321 +// (e.g. \b, \n, \t) are interpreted before the result reaches the regexp
1322 +// engine. A pattern that needs a literal backslash escape meant for the
1323 +// regexp engine, such as \b for a word boundary, should be written as a
1324 +// CEL raw string (prefixed with r) so CEL passes the backslash through
1325 +// unchanged: expression header_regexp('foo', 'User-Agent', r'bot\b').
1326 +// Without the r prefix, \b is interpreted by CEL as a backspace
1327 +// character before the regexp engine ever sees the pattern.
1328 func (MatchHeaderRE) CELLibrary(ctx caddy.Context) (cel.Library, error) {
1329 unnamedPattern, err := CELMatcherImpl(
1330 "header_regexp",