From 31e4f84f9a2b5bdc33a4b49c4b668bb4447af278 Mon Sep 17 00:00:00 2001 From: Ralph Slooten Date: Sat, 13 Apr 2024 00:25:48 +1200 Subject: [PATCH] Chore: Remove deprecated --disable-html-check option --- cmd/root.go | 12 ++++++++---- config/config.go | 11 ++++++++--- server/apiv1/webui.go | 4 ---- server/server.go | 4 +--- server/ui/api/v1/swagger.json | 4 ---- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index e38c5dc..b6e2bc1 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -96,7 +96,6 @@ func init() { rootCmd.Flags().StringVar(&config.UITLSCert, "ui-tls-cert", config.UITLSCert, "TLS certificate for web UI (HTTPS) - requires ui-tls-key") rootCmd.Flags().StringVar(&config.UITLSKey, "ui-tls-key", config.UITLSKey, "TLS key for web UI (HTTPS) - requires ui-tls-cert") rootCmd.Flags().StringVar(&server.AccessControlAllowOrigin, "api-cors", server.AccessControlAllowOrigin, "Set API CORS Access-Control-Allow-Origin header") - rootCmd.Flags().BoolVar(&config.DisableHTMLCheck, "disable-html-check", config.DisableHTMLCheck, "Disable the HTML check functionality (web UI & API)") rootCmd.Flags().BoolVar(&config.BlockRemoteCSSAndFonts, "block-remote-css-and-fonts", config.BlockRemoteCSSAndFonts, "Block access to remote CSS & fonts") rootCmd.Flags().StringVar(&config.EnableSpamAssassin, "enable-spamassassin", config.EnableSpamAssassin, "Enable integration with SpamAssassin") rootCmd.Flags().BoolVar(&config.AllowUntrustedTLS, "allow-untrusted-tls", config.AllowUntrustedTLS, "Do not verify HTTPS certificates (link checker & screenshots)") @@ -155,6 +154,10 @@ func init() { rootCmd.Flags().BoolVar(&config.SMTPRequireSTARTTLS, "smtp-tls-required", config.SMTPRequireSTARTTLS, "smtp-require-starttls") rootCmd.Flags().Lookup("smtp-tls-required").Hidden = true rootCmd.Flags().Lookup("smtp-tls-required").Deprecated = "use --smtp-require-starttls" + + // DEPRECATED FLAG 2024/04/13 - no longer used + rootCmd.Flags().BoolVar(&config.DisableHTMLCheck, "disable-html-check", config.DisableHTMLCheck, "Disable the HTML check functionality (web UI & API)") + rootCmd.Flags().Lookup("disable-html-check").Hidden = true } // Load settings from environment @@ -201,9 +204,6 @@ func initConfigFromEnv() { if len(os.Getenv("MP_API_CORS")) > 0 { server.AccessControlAllowOrigin = os.Getenv("MP_API_CORS") } - if getEnabledFromEnv("MP_DISABLE_HTML_CHECK") { - config.DisableHTMLCheck = true - } if getEnabledFromEnv("MP_BLOCK_REMOTE_CSS_AND_FONTS") { config.BlockRemoteCSSAndFonts = true } @@ -333,6 +333,10 @@ func initDeprecatedConfigFromEnv() { logger.Log().Warn("ENV MP_SMTP_TLS_REQUIRED has been deprecated, use MP_SMTP_REQUIRE_STARTTLS") config.SMTPRequireSTARTTLS = true } + if getEnabledFromEnv("MP_DISABLE_HTML_CHECK") { + logger.Log().Warn("ENV MP_DISABLE_HTML_CHECK has been deprecated and is no longer used") + config.DisableHTMLCheck = true + } } // Wrapper to get a boolean from an environment variable diff --git a/config/config.go b/config/config.go index c5522cb..019b9f4 100644 --- a/config/config.go +++ b/config/config.go @@ -83,9 +83,6 @@ var ( // IgnoreDuplicateIDs will skip messages with the same ID IgnoreDuplicateIDs bool - // DisableHTMLCheck used to disable the HTML check in bother the API and web UI - DisableHTMLCheck = false - // BlockRemoteCSSAndFonts used to disable remote CSS & fonts BlockRemoteCSSAndFonts = false @@ -153,6 +150,9 @@ var ( // RepoBinaryName on Github for updater RepoBinaryName = "mailpit" + + // DisableHTMLCheck DEPRECATED 2024/04/13 - kept here to display console warning only + DisableHTMLCheck = false ) // AutoTag struct for auto-tagging @@ -361,6 +361,11 @@ func VerifyConfig() error { return fmt.Errorf("webhook URL does not appear to be a valid URL (%s)", WebhookURL) } + // DEPRECATED 2024/04/13 + if DisableHTMLCheck { + logger.Log().Warn("--disable-html-check has been deprecated and is no longer used") + } + if EnableSpamAssassin != "" { spamassassin.SetService(EnableSpamAssassin) logger.Log().Infof("[spamassassin] enabled via %s", EnableSpamAssassin) diff --git a/server/apiv1/webui.go b/server/apiv1/webui.go index 0b134c3..40015f8 100644 --- a/server/apiv1/webui.go +++ b/server/apiv1/webui.go @@ -27,9 +27,6 @@ type webUIConfiguration struct { RecipientAllowlist string } - // Whether the HTML check has been globally disabled - DisableHTMLCheck bool - // Whether SpamAssassin is enabled SpamAssassin bool @@ -65,7 +62,6 @@ func WebUIConfig(w http.ResponseWriter, _ *http.Request) { conf.MessageRelay.RecipientAllowlist = config.SMTPRelayConfig.AllowedRecipients } - conf.DisableHTMLCheck = config.DisableHTMLCheck conf.SpamAssassin = config.EnableSpamAssassin != "" conf.DuplicatesIgnored = config.IgnoreDuplicateIDs diff --git a/server/server.go b/server/server.go index cd4ddb8..0471395 100644 --- a/server/server.go +++ b/server/server.go @@ -129,9 +129,7 @@ func apiRoutes() *mux.Router { r.HandleFunc(config.Webroot+"api/v1/message/{id}/headers", middleWareFunc(apiv1.GetHeaders)).Methods("GET") r.HandleFunc(config.Webroot+"api/v1/message/{id}/raw", middleWareFunc(apiv1.DownloadRaw)).Methods("GET") r.HandleFunc(config.Webroot+"api/v1/message/{id}/release", middleWareFunc(apiv1.ReleaseMessage)).Methods("POST") - if !config.DisableHTMLCheck { - r.HandleFunc(config.Webroot+"api/v1/message/{id}/html-check", middleWareFunc(apiv1.HTMLCheck)).Methods("GET") - } + r.HandleFunc(config.Webroot+"api/v1/message/{id}/html-check", middleWareFunc(apiv1.HTMLCheck)).Methods("GET") r.HandleFunc(config.Webroot+"api/v1/message/{id}/link-check", middleWareFunc(apiv1.LinkCheck)).Methods("GET") if config.EnableSpamAssassin != "" { r.HandleFunc(config.Webroot+"api/v1/message/{id}/sa-check", middleWareFunc(apiv1.SpamAssassinCheck)).Methods("GET") diff --git a/server/ui/api/v1/swagger.json b/server/ui/api/v1/swagger.json index 74cc145..c991ee0 100644 --- a/server/ui/api/v1/swagger.json +++ b/server/ui/api/v1/swagger.json @@ -1401,10 +1401,6 @@ "description": "Response includes global web UI settings", "type": "object", "properties": { - "DisableHTMLCheck": { - "description": "Whether the HTML check has been globally disabled", - "type": "boolean" - }, "DuplicatesIgnored": { "description": "Whether messages with duplicate IDs are ignored", "type": "boolean"