1
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-16 21:56:40 -05:00

httpcaddyfile: Avoid repeated subjects in APs (fix #3618)

When consolidating automation policies, ensure same subject names do not
get appended to list.
This commit is contained in:
Matthew Holt 2020-08-06 13:56:23 -06:00
parent 584eba94a4
commit ff19bddac5
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5

View file

@ -444,7 +444,12 @@ func consolidateAutomationPolicies(aps []*caddytls.AutomationPolicy) []*caddytls
} else if len(aps[i].Subjects) > 0 && len(aps[j].Subjects) == 0 {
aps = append(aps[:i], aps[i+1:]...)
} else {
aps[i].Subjects = append(aps[i].Subjects, aps[j].Subjects...)
// avoid repeated subjects
for _, subj := range aps[j].Subjects {
if !sliceContains(aps[i].Subjects, subj) {
aps[i].Subjects = append(aps[i].Subjects, subj)
}
}
aps = append(aps[:j], aps[j+1:]...)
}
i--