Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 13, 10:30 UTC
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...
Matt Holt committed
Sep 29, 2022 at 12:46 UTC
5e52bbb1369b7444700427539e4dd532ed13ac6d
1 file changed
+1
-10
modules/caddyhttp/map/map.go
+1
-10
@@ -109,22 +109,13 @@ func (h *Handler) Validate() error {
109
}
110
seen[input] = i
111
112
- // prevent infinite recursion
113
- for _, out := range m.Outputs {
114
- for _, dest := range h.Destinations {
115
- if strings.Contains(caddy.ToString(out), dest) ||
116
- strings.Contains(m.Input, dest) {
117
- return fmt.Errorf("mapping %d requires value of {%s} to define value of {%s}: infinite recursion", i, dest, dest)
118
- }
119
- }
120
- }
121
-
112
// ensure mappings have 1:1 output-to-destination correspondence
113
nOut := len(m.Outputs)
114
if nOut != nDest {
115
return fmt.Errorf("mapping %d has %d outputs but there are %d destinations defined", i, nOut, nDest)
116
}
117
}
118
+
119
return nil
120
}
121