luci-lilb-nixio: Code quality fixes
authorPaul Donald <newtwen@gmail.com>
Wed, 31 Jan 2024 01:25:33 +0000 (02:25 +0100)
committerPaul Donald <newtwen@gmail.com>
Wed, 31 Jan 2024 01:55:05 +0000 (02:55 +0100)
future variants could use en/decodeURIComponent

ordering is important when handling "&"

Signed-off-by: Paul Donald <newtwen@gmail.com>
libs/luci-lib-nixio/axTLS/www/index.html

index 25cd2e69b1a4ea981882ecad956e3976a8a434a2..9896cd8a5466a79abdd314dd36270d018633b57a 100755 (executable)
@@ -5943,10 +5943,10 @@ String.prototype.htmlEncode = function()
        return(this.replace(/&/mg,"&amp;").replace(/</mg,"&lt;").replace(/>/mg,"&gt;").replace(/\"/mg,"&quot;"));
 }
 
-// Convert "&amp;" to &, "&lt;" to <, "&gt;" to > and "&quot;" to "
+// Convert "&lt;" to <, "&gt;" to >, "&quot;" to " and "&amp;" to & (& handled last for security reasons)
 String.prototype.htmlDecode = function()
 {
-       return(this.replace(/&amp;/mg,"&").replace(/&lt;/mg,"<").replace(/&gt;/mg,">").replace(/&quot;/mg,"\""));
+       return(this.replace(/&lt;/mg,"<").replace(/&gt;/mg,">").replace(/&quot;/mg,"\"").replace(/&amp;/mg,"&"));
 }
 
 // Parse a space-separated string of name:value parameters where: