From da1888a7fad3be8a42b326e24bd676c92a7e4c51 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 16 Nov 2014 11:09:53 +0100 Subject: [ticket/security-171] Use type cast helper for json data SECURITY-171 --- phpBB/phpbb/version_helper.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'phpBB/phpbb/version_helper.php') diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php index c3c3602944..3c5f3efcf2 100644 --- a/phpBB/phpbb/version_helper.php +++ b/phpBB/phpbb/version_helper.php @@ -259,6 +259,13 @@ class version_helper $info = json_decode($info, true); + // Sanitize any data we retrieve from a server + $json_sanitizer = function(&$value, $key) { + $type_cast_helper = new \phpbb\request\type_cast_helper(); + $type_cast_helper->set_var($value, $value, gettype($value), true); + }; + array_walk_recursive($info, $json_sanitizer); + if (empty($info['stable']) && empty($info['unstable'])) { $this->user->add_lang('acp/common'); @@ -266,15 +273,6 @@ class version_helper throw new \RuntimeException($this->user->lang('VERSIONCHECK_FAIL')); } - // Replace & with & on announcement links - foreach ($info as $stability => $branches) - { - foreach ($branches as $branch => $branch_data) - { - $info[$stability][$branch]['announcement'] = (!empty($branch_data['announcement'])) ? str_replace('&', '&', $branch_data['announcement']) : ''; - } - } - $info['stable'] = (empty($info['stable'])) ? array() : $info['stable']; $info['unstable'] = (empty($info['unstable'])) ? $info['stable'] : $info['unstable']; -- cgit v1.2.1 From 4ee05b1c17fa1be0c911c9d37e106f19b23ebac2 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 17 Nov 2014 00:33:51 +0100 Subject: [ticket/security-171] Add tests for retrieved remote data in version_helper SECURITY-171 --- phpBB/phpbb/version_helper.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/version_helper.php') diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php index 3c5f3efcf2..bcc67712e4 100644 --- a/phpBB/phpbb/version_helper.php +++ b/phpBB/phpbb/version_helper.php @@ -260,11 +260,14 @@ class version_helper $info = json_decode($info, true); // Sanitize any data we retrieve from a server - $json_sanitizer = function(&$value, $key) { - $type_cast_helper = new \phpbb\request\type_cast_helper(); - $type_cast_helper->set_var($value, $value, gettype($value), true); - }; - array_walk_recursive($info, $json_sanitizer); + if (!empty($info)) + { + $json_sanitizer = function (&$value, $key) { + $type_cast_helper = new \phpbb\request\type_cast_helper(); + $type_cast_helper->set_var($value, $value, gettype($value), true); + }; + array_walk_recursive($info, $json_sanitizer); + } if (empty($info['stable']) && empty($info['unstable'])) { -- cgit v1.2.1