Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
caddyfile: Error on invalid site addresses containing comma (#4302)
Some users forget to use a comma between their site addresses. This is invalid (commas aren't a valid character in domains) and later parts of the code like certificate automation will try to use this otherwise, which doesn't make sense. Best to error as early as possible. Example thread on the forums where this happened: https://caddy.community/t/simplify-caddyfile/13281/9
Francis Lavoie committed
Aug 23, 2021 at 13:26 UTC
d74913f871414ddac9a3884fc6aef4492ee4f65f
1 file changed
+7
caddyconfig/caddyfile/parse.go
+7
@@ -229,6 +229,13 @@ func (p *parser) addresses() error {
229
expectingAnother = false // but we may still see another one on this line
230
}
231
232
+ // If there's a comma here, it's probably because they didn't use a space
233
+ // between their two domains, e.g. "foo.com,bar.com", which would not be
234
+ // parsed as two separate site addresses.
235
+ if strings.Contains(tkn, ",") {
236
+ return p.Errf("Site addresses cannot contain a comma ',': '%s' - put a space after the comma to separate site addresses", tkn)
237
+ }
238
+
239
p.block.Keys = append(p.block.Keys, tkn)
240
}
241