From 7f740ccb5a13da1888c724e81991a257f5c5ed61 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Mon, 12 Jul 2021 15:47:38 -0400 Subject: [PATCH] authorization: add warning if a domian in "cors_domains" contains a trailing slash Signed-off-by: Eric Callahan --- moonraker/components/authorization.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/moonraker/components/authorization.py b/moonraker/components/authorization.py index 695f7da..c64c47e 100644 --- a/moonraker/components/authorization.py +++ b/moonraker/components/authorization.py @@ -119,8 +119,14 @@ class Authorization: raise config.error( f"Unsafe CORS Domain '{domain}'. Wildcards are not" " permitted in the top level domain.") - self.cors_domains.append( - domain.replace(".", "\\.").replace("*", ".*")) + if domain.endswith("/"): + self.server.add_warning( + f"Invalid domain '{domain}' in option 'cors_domains', " + "section [authorization]. Domain's cannot contain a " + "trailing slash.") + else: + self.cors_domains.append( + domain.replace(".", "\\.").replace("*", ".*")) # Get Trusted Clients self.trusted_ips: List[IPAddr] = []