From 5e52bbb1369b7444700427539e4dd532ed13ac6d Mon Sep 17 00:00:00 2001 From: Matt Holt Date: Thu, 29 Sep 2022 12:46:38 -0600 Subject: 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... --- modules/caddyhttp/map/map.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'modules/caddyhttp/map') diff --git a/modules/caddyhttp/map/map.go b/modules/caddyhttp/map/map.go index b972534..fbd1e40 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 } -- cgit v1.2.3