Powerful and easy to use cms to build websites, blogs or ecommerce stores.
HTML backendblogblog-engineblog-platformbloggingcmscontent-managementcontent-management-systemecommerceecommerce-platformno-codepage-builderphpphp-cmsphp7php8self-hostedshopping-cartweb-applicationwebsite-builder
Added sanitize to user bio on profile save, fixed sanitizeHTML to prevent more XSS variants, reported by @JosanGeorge
givanz20a01ef08559
diff --git a/app/controller/user/profile.php b/app/controller/user/profile.phpold mode 100755new mode 100644index 9210fc7..a1a8934--- a/app/controller/user/profile.php+++ b/app/controller/user/profile.php@@ -23,6 +23,7 @@namespace Vvveb\Controller\User;use function Vvveb\__;+use function Vvveb\sanitizeHTML;use Vvveb\Sql\UserSQL;use Vvveb\System\User\User;use Vvveb\System\Validator;@@ -66,8 +67,9 @@ class Profile extends Base {if (($errors = $validator->validate($this->request->post['user'])) === true) {$user = $this->request->post['user'];$user['user_id'] = $this->global['user_id'];+ $user['bio'] = sanitizeHTML($user['bio'] ?? '');unset($user['username'], $user['status'], $user['user'], $user['token'], $user['created_at']);-+$result = User::update($user, ['user_id' => $this->global['user_id']]);if (! $result) {diff --git a/system/functions.php b/system/functions.phpindex 84c2b67..204bf3a 100755--- a/system/functions.php+++ b/system/functions.php@@ -1429,7 +1429,7 @@ function stripTagsArray($array, $tags) {return $array;}-function stripChars($string, $chars = ['(', ')' , '{' , '}', ':', '<' , '>']) {+function stripChars($string, $chars = ['(', ')', '{', '}', ':', '<', '>']) {return str_replace($chars, '', $string);}@@ -1447,7 +1447,7 @@ function sanitizeHTML($string) {$string = html_entity_decode($string, ENT_COMPAT, 'UTF-8');// Remove any attribute starting with "on" or xmlns- $string = preg_replace('#(<[^>]+?[\x00-\x20"\'])(?:on|xmlns)[^>]*+>#iu', '$1>', $string);+ $string = preg_replace('#(<[^>]+?[\x00-\x20"\'/])(?:on|xmlns)[^>]*+>#iu', '$1>', $string);// Remove javascript: and vbscript: protocols$string = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([`\'"]*)[\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iu', '$1=$2nojavascript...', $string);@@ -1467,7 +1467,7 @@ function sanitizeHTML($string) {$old_data = $string;//$string = preg_replace('#</*(?:applet|b(?:ase|gsound|link)|embed|frame(?:set)?|i(?:frame|layer)|l(?:ayer|ink)|meta|object|s(?:cript|tyle)|title|xml)[^>]*+>#i', '', $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);+ } while ($old_data !== $string);//restore entities$string = str_replace(['<<', '>>'], ['<', '>'], $string);