From 9fac75b831ca7dfd2408b0ceebb24070863405cb Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Thu, 20 Jan 2022 13:20:04 -0500 Subject: [PATCH] Check base URL format --- cmd/serve.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/serve.go b/cmd/serve.go index 914a9fc9..63119b9d 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -9,6 +9,7 @@ import ( "heckel.io/ntfy/util" "log" "math" + "strings" "time" ) @@ -123,6 +124,8 @@ func execServe(c *cli.Context) error { return errors.New("if smtp-server-listen is set, smtp-server-domain must also be set") } else if attachmentCacheDir != "" && baseURL == "" { return errors.New("if attachment-cache-dir is set, base-url must also be set") + } else if baseURL != "" && (strings.HasPrefix(baseURL, "http://") || strings.HasPrefix(baseURL, "https://")) { + return errors.New("if set, base-url must start with http:// or https://") } // Special case: Unset default