mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-16 21:56:40 -05:00
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...
This commit is contained in:
parent
fcdbc69fab
commit
5e52bbb136
1 changed files with 1 additions and 10 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue