diff --git a/scripts/lua/modules/alert_utils.lua b/scripts/lua/modules/alert_utils.lua
index 98e3293852..eb8c7c8556 100644
--- a/scripts/lua/modules/alert_utils.lua
+++ b/scripts/lua/modules/alert_utils.lua
@@ -2041,7 +2041,6 @@ function alert_utils.formatAlertNotification(notif, options)
if options.nohtml then
msg = msg .. noHtml(alert_message)
- msg = msg:gsub(' ', "")
else
msg = msg .. alert_message
end
diff --git a/scripts/lua/modules/lua_utils.lua b/scripts/lua/modules/lua_utils.lua
index aad6ee4915..f73a218f16 100644
--- a/scripts/lua/modules/lua_utils.lua
+++ b/scripts/lua/modules/lua_utils.lua
@@ -650,10 +650,13 @@ function noHtml(s)
return (gsub( str, '(&(#?x?)([%d%a]+);)', entitySwap ))
end
- local cleaned = s:gsub("<[aA].->(.-)[aA]>","%1")
+ local cleaned = s:gsub("<[aA] .->(.-)[aA]>","%1")
+ :gsub("(.-)","%1")
+ :gsub("(.-)","%1")
:gsub("%s*<[iI].->(.-)[iI]>","%1")
- :gsub("<.->(.-)","%1") -- note: this does not handle nested tags
+ :gsub("<.->(.-)","%1") -- note: keep as last as this does not handle nested tags
:gsub("^%s*(.-)%s*$", "%1")
+ :gsub(' ', " ")
return unescape(cleaned)
end