1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-21 00:02:18 +02:00

[ticket/10824] Switch to new namespace for json sanitizer

PHPBB3-10824
This commit is contained in:
Marc Alexander 2020-01-20 20:09:10 +01:00
parent 27c69c2740
commit 93949d1be4
No known key found for this signature in database
GPG Key ID: 50E0D2423696F995
6 changed files with 26 additions and 25 deletions

View File

@ -1203,7 +1203,7 @@ class acp_styles
}
$json = file_get_contents($this->styles_path . $dir . '/composer.json');
$style_data = \phpbb\json_sanitizer::decode($json);
$style_data = \phpbb\json\sanitizer::decode($json);
if (!is_array($style_data) || !isset($style_data['type']) || $style_data['type'] !== 'phpbb-style')
{

View File

@ -13,7 +13,7 @@
namespace phpbb\cache;
use phpbb\json_sanitizer;
use phpbb\json\sanitizer;
/**
* Class for grabbing/handling cached entries
@ -357,7 +357,7 @@ class service
{
// Re-parse cfg file
$json = file_get_contents($filename);
$parsed_array = json_sanitizer::decode($json);
$parsed_array = sanitizer::decode($json);
$parsed_array['filetime'] = @filemtime($filename);
$this->driver->put('_cfg_' . $style['style_path'], $parsed_array);

View File

@ -13,7 +13,7 @@
namespace phpbb\db\migration\data\v310;
use phpbb\json_sanitizer;
use phpbb\json\sanitizer;
class style_update_p1 extends \phpbb\db\migration\migration
{
@ -85,7 +85,7 @@ class style_update_p1 extends \phpbb\db\migration\migration
else if (file_exists($fileinfo->getPathname() . '/composer.json'))
{
$json = file_get_contents($fileinfo->getPathname() . '/composer.json');
$style_data = json_sanitizer::decode($json);
$style_data = sanitizer::decode($json);
if (isset($style_data['extra']['phpbb-version']) && version_compare($style_data['extra']['phpbb-version'], '3.3.0-dev', '>='))
{
// 3.3 style

View File

@ -1,24 +1,25 @@
<?php
declare(strict_types=1);
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb;
namespace phpbb\json;
use phpbb\request\type_cast_helper;
/**
* JSON sanitizer class
*/
class json_sanitizer
* JSON sanitizer class
*/
class sanitizer
{
/**
* Sanitize json data
@ -27,7 +28,7 @@ class json_sanitizer
*
* @return array Sanitized data
*/
static public function sanitize($data)
static public function sanitize(array $data) : array
{
if (!empty($data))
{
@ -48,7 +49,7 @@ class json_sanitizer
*
* @return array Data array
*/
static public function decode($json)
static public function decode(string $json) : array
{
$data = json_decode($json, true);
return !empty($data) ? self::sanitize($data) : [];

View File

@ -13,7 +13,7 @@
namespace phpbb\language;
use phpbb\json_sanitizer;
use phpbb\json\sanitizer;
use Symfony\Component\Finder\Finder;
/**
@ -55,7 +55,7 @@ class language_file_helper
foreach ($finder as $file)
{
$json = $file->getContents();
$data = json_sanitizer::decode($json);
$data = sanitizer::decode($json);
$available_languages[] = $this->get_language_data_from_json($data);
}
@ -72,7 +72,7 @@ class language_file_helper
public function get_language_data_from_composer_file($path)
{
$json_data = file_get_contents($path);
return $this->get_language_data_from_json(json_sanitizer::decode($json_data));
return $this->get_language_data_from_json(sanitizer::decode($json_data));
}
/**

View File

@ -390,7 +390,7 @@ class version_helper
}
// Sanitize any data we retrieve from a server
$info = json_sanitizer::decode($info);
$info = json\sanitizer::decode($info);
if (empty($info['stable']) && empty($info['unstable']))
{