From 6fd092b5df6f96530fec8ba1aec426b6d59b822b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 3 Nov 2014 16:24:09 +0100 Subject: [PATCH] [ticket/13280] Correctly format user page for build_url() PHPBB3-13280 --- phpBB/includes/functions.php | 3 ++- tests/functions/build_url_test.php | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 1a3560dbb1..56363ed5c0 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2397,7 +2397,8 @@ function build_url($strip_vars = false) global $config, $user, $phpbb_path_helper; $php_ext = $phpbb_path_helper->get_php_ext(); - $page = $user->page['page']; + // Change page back to expected format + $page = str_replace('&', '&', urldecode($user->page['page'])); // We need to be cautious here. // On some situations, the redirect path is an absolute URL, sometimes a relative path diff --git a/tests/functions/build_url_test.php b/tests/functions/build_url_test.php index 06415a424e..df178f277e 100644 --- a/tests/functions/build_url_test.php +++ b/tests/functions/build_url_test.php @@ -79,9 +79,16 @@ class phpbb_build_url_test extends phpbb_test_case { global $user, $phpbb_root_path; - $user->page['page'] = $page; + $user->page['page'] = str_replace('%2F', '/', urlencode($this->sanitizer($page))); $output = build_url($strip_vars); $this->assertEquals($expected, $output); } + + protected function sanitizer($value) + { + $type_cast_helper = new \phpbb\request\type_cast_helper(); + $type_cast_helper->set_var($value, $value, gettype($value), true); + return $value; + } }