aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatt Holt <[email protected]>2022-09-29 12:46:38 -0600
committerGitHub <[email protected]>2022-09-29 12:46:38 -0600
commit5e52bbb1369b7444700427539e4dd532ed13ac6d (patch)
tree8a7016ab99d10c2157298bca7d4076969d332122
parentfcdbc69fabd14c6d0b1fe5c5e07490bf27d7f8bd (diff)
downloadcaddy-5e52bbb1369b7444700427539e4dd532ed13ac6d.tar.gz
caddy-5e52bbb1369b7444700427539e4dd532ed13ac6d.zip
map: Remove infinite recursion check (#5094)
It was not accurate. Placeholders could be used in outputs that are defined in the same mapping as long as that placeholder does not do the same. A more general solution would be to detect it at run-time in the replacer directly, but that's a bit tedious and will require allocations I think. A better implementation of this check could still be done, but I don't know if it would always be accurate. Could be a "best-effort" thing? But I've also never heard of an actual case where someone configured infinite recursion...
-rw-r--r--modules/caddyhttp/map/map.go11
1 files changed, 1 insertions, 10 deletions
diff --git a/modules/caddyhttp/map/map.go b/modules/caddyhttp/map/map.go
index b972534b0..fbd1e4058 100644
--- a/modules/caddyhttp/map/map.go
+++ b/modules/caddyhttp/map/map.go
@@ -109,22 +109,13 @@ func (h *Handler) Validate() error {
}
seen[input] = i
- // prevent infinite recursion
- for _, out := range m.Outputs {
- for _, dest := range h.Destinations {
- if strings.Contains(caddy.ToString(out), dest) ||
- strings.Contains(m.Input, dest) {
- return fmt.Errorf("mapping %d requires value of {%s} to define value of {%s}: infinite recursion", i, dest, dest)
- }
- }
- }
-
// ensure mappings have 1:1 output-to-destination correspondence
nOut := len(m.Outputs)
if nOut != nDest {
return fmt.Errorf("mapping %d has %d outputs but there are %d destinations defined", i, nOut, nDest)
}
}
+
return nil
}