Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Changed sanitizeHTML to strip javascript code inside tags with escaped entities, fix for GHSA-39gc-pjv5-4w4p reported by @elvinsuleymanov

givanz7e02b0e1a375
diff --git a/system/functions.php b/system/functions.php
index e179bc9..9ef7b45 100755
--- a/system/functions.php
+++ b/system/functions.php
@@ -1434,9 +1434,9 @@ function sanitizeHTML($string) {
return $string;
}
- //$string = stripTags($string);
-
// Fix &entity\n;
+ //add <> before tag entities to allow regex matching
+ $string = str_replace(['&lt;', '&gt;'], ['&lt;<', '>&gt;'], $string);
$string = str_replace(['&amp;', '&lt;', '&gt;'], ['&amp;amp;', '&amp;lt;', '&amp;gt;'], $string);
$string = preg_replace('/(&#*\w+)[\x00-\x20]+;/u', '$1;', $string);
$string = preg_replace('/(&#x*[0-9A-F]+);*/iu', '$1;', $string);
@@ -1465,6 +1465,8 @@ function sanitizeHTML($string) {
$string = preg_replace('#</*(?:applet|b(?:ase|gsound|link)|embed|frame(?:set)?|i(?:layer)|l(?:ayer|ink)|meta|object|s(?:cript|tyle)|title|xml)[^>]*+>#i', '', $string);
} while ($string !== $string);
+ //restore entities
+ $string = str_replace(['&lt;<', '>&gt;'], ['&lt;', '&gt;'], $string);
return $string;
}