diff --git a/phpBB/phpbb/json_sanitizer.php b/phpBB/phpbb/json_sanitizer.php index 1a1d8aef3a..157502624f 100644 --- a/phpBB/phpbb/json_sanitizer.php +++ b/phpBB/phpbb/json_sanitizer.php @@ -13,6 +13,8 @@ namespace phpbb; +use phpbb\request\type_cast_helper; + /** * JSON sanitizer class */ @@ -30,7 +32,7 @@ class json_sanitizer if (!empty($data)) { $json_sanitizer = function (&$value, $key) { - $type_cast_helper = new \phpbb\request\type_cast_helper(); + $type_cast_helper = new type_cast_helper(); $type_cast_helper->set_var($value, $value, gettype($value), true); }; array_walk_recursive($data, $json_sanitizer); @@ -38,4 +40,16 @@ class json_sanitizer return $data; } + + /** + * Decode and sanitize json data + * + * @param string $json JSON data string + * + * @return array Data array + */ + static public function decode($json) + { + return self::sanitize(json_decode($json, true)); + } }