aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAziz Rmadi <[email protected]>2024-03-23 00:51:34 -0500
committerGitHub <[email protected]>2024-03-23 01:51:34 -0400
commitdb9d16735458be441abcb12b477d9d1fe630687e (patch)
treed8458bfb5b1a4e25195040ec321327ae2aae7808
parent29f57faa8679344fa40ea9b317d724f0604d5b40 (diff)
downloadcaddy-db9d16735458be441abcb12b477d9d1fe630687e.tar.gz
caddy-db9d16735458be441abcb12b477d9d1fe630687e.zip
Added a null check to avoid segfault on rewrite query ops (#6191)
-rw-r--r--modules/caddyhttp/rewrite/rewrite.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/modules/caddyhttp/rewrite/rewrite.go b/modules/caddyhttp/rewrite/rewrite.go
index 3479f0649..9a4995186 100644
--- a/modules/caddyhttp/rewrite/rewrite.go
+++ b/modules/caddyhttp/rewrite/rewrite.go
@@ -117,13 +117,15 @@ func (rewr *Rewrite) Provision(ctx caddy.Context) error {
}
rep.re = re
}
-
- for _, replacementOp := range rewr.Query.Replace {
- err := replacementOp.Provision(ctx)
- if err != nil {
- return fmt.Errorf("compiling regular expression %s in query rewrite replace operation: %v", replacementOp.SearchRegexp, err)
+ if rewr.Query != nil {
+ for _, replacementOp := range rewr.Query.Replace {
+ err := replacementOp.Provision(ctx)
+ if err != nil {
+ return fmt.Errorf("compiling regular expression %s in query rewrite replace operation: %v", replacementOp.SearchRegexp, err)
+ }
}
}
+
return nil
}