aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php14
-rw-r--r--phpBB/includes/functions.php27
-rw-r--r--phpBB/phpbb/path_helper.php34
-rw-r--r--phpBB/styles/prosilver/theme/content.css3
-rw-r--r--tests/path_helper/path_helper_test.php25
5 files changed, 73 insertions, 30 deletions
diff --git a/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php b/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php
index 87e676b8ff..18cb8ba82e 100644
--- a/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php
+++ b/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php
@@ -24,7 +24,7 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
return array(T_USE);
}
- protected function check($found_name, $full_name, $short_name, $line)
+ protected function check($phpcsFile, $found_name, $full_name, $short_name, $line)
{
if ($found_name === $full_name)
@@ -91,7 +91,7 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
$simple_class_name = trim($phpcsFile->getTokensAsString($simple_class_name_start, ($simple_class_name_end - $simple_class_name_start)));
- $ok = $this->check($simple_class_name, $class_name_full, $class_name_short, $simple_statement) ? true : $ok;
+ $ok = $this->check($phpcsFile, $simple_class_name, $class_name_full, $class_name_short, $simple_statement) ? true : $ok;
}
}
@@ -106,7 +106,7 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
$paamayim_nekudotayim_class_name = trim($phpcsFile->getTokensAsString($paamayim_nekudotayim_class_name_start + 1, ($paamayim_nekudotayim_class_name_end - $paamayim_nekudotayim_class_name_start)));
- $ok = $this->check($paamayim_nekudotayim_class_name, $class_name_full, $class_name_short, $paamayim_nekudotayim) ? true : $ok;
+ $ok = $this->check($phpcsFile, $paamayim_nekudotayim_class_name, $class_name_full, $class_name_short, $paamayim_nekudotayim) ? true : $ok;
}
// Checks in implements
@@ -125,7 +125,7 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
$implements_class_name = trim($phpcsFile->getTokensAsString($implements_class_name_start, ($implements_class_name_end - $implements_class_name_start)));
- $ok = $this->check($implements_class_name, $class_name_full, $class_name_short, $implements) ? true : $ok;
+ $ok = $this->check($phpcsFile, $implements_class_name, $class_name_full, $class_name_short, $implements) ? true : $ok;
}
}
@@ -163,7 +163,7 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
$types = explode('|', str_replace('[]', '', $type));
foreach ($types as $type)
{
- $ok = $this->check($type, $class_name_full, $class_name_short, $param->getLine() + $comment_start) ? true : $ok;
+ $ok = $this->check($phpcsFile, $type, $class_name_full, $class_name_short, $param->getLine() + $comment_start) ? true : $ok;
}
}
@@ -175,7 +175,7 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
$types = explode('|', str_replace('[]', '', $type));
foreach ($types as $type)
{
- $ok = $this->check($type, $class_name_full, $class_name_short, $return->getLine() + $comment_start) ? true : $ok;
+ $ok = $this->check($phpcsFile, $type, $class_name_full, $class_name_short, $return->getLine() + $comment_start) ? true : $ok;
}
}
}
@@ -191,7 +191,7 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
$params = $phpcsFile->getMethodParameters($function_declaration);
foreach ($params as $param)
{
- $ok = $this->check($param['type_hint'], $class_name_full, $class_name_short, $function_declaration) ? true : $ok;
+ $ok = $this->check($phpcsFile, $param['type_hint'], $class_name_full, $class_name_short, $function_declaration) ? true : $ok;
}
}
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 321394639b..97429a0be4 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -2396,26 +2396,7 @@ function build_url($strip_vars = false)
{
global $config, $user, $phpbb_path_helper;
- $php_ext = $phpbb_path_helper->get_php_ext();
- $page = $user->page['page'];
-
- // We need to be cautious here.
- // On some situations, the redirect path is an absolute URL, sometimes a relative path
- // For a relative path, let's prefix it with $phpbb_root_path to point to the correct location,
- // else we use the URL directly.
- $url_parts = parse_url($page);
-
- // URL
- if ($url_parts === false || empty($url_parts['scheme']) || empty($url_parts['host']))
- {
- // Remove 'app.php/' from the page, when rewrite is enabled
- if ($config['enable_mod_rewrite'] && strpos($page, 'app.' . $php_ext . '/') === 0)
- {
- $page = substr($page, strlen('app.' . $php_ext . '/'));
- }
-
- $page = $phpbb_path_helper->get_phpbb_root_path() . $page;
- }
+ $page = $phpbb_path_helper->get_valid_page($user->page['page'], $config['enable_mod_rewrite']);
// Append SID
$redirect = append_sid($page, false, false);
@@ -2657,7 +2638,7 @@ function check_form_key($form_name, $timespan = false)
function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_body.html', $u_action = '')
{
global $user, $template, $db, $request;
- global $phpEx, $phpbb_root_path, $request;
+ global $config, $phpbb_path_helper;
if (isset($_POST['cancel']))
{
@@ -2719,8 +2700,8 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo
}
// re-add sid / transform & to & for user->page (user->page is always using &)
- $use_page = ($u_action) ? $phpbb_root_path . $u_action : $phpbb_root_path . str_replace('&', '&', $user->page['page']);
- $u_action = reapply_sid($use_page);
+ $use_page = ($u_action) ? $u_action : str_replace('&', '&', $user->page['page']);
+ $u_action = reapply_sid($phpbb_path_helper->get_valid_page($use_page, $config['enable_mod_rewrite']));
$u_action .= ((strpos($u_action, '?') === false) ? '?' : '&') . 'confirm_key=' . $confirm_key;
$template->assign_vars(array(
diff --git a/phpBB/phpbb/path_helper.php b/phpBB/phpbb/path_helper.php
index b49d8d13c2..5400c1c5a6 100644
--- a/phpBB/phpbb/path_helper.php
+++ b/phpBB/phpbb/path_helper.php
@@ -455,4 +455,38 @@ class path_helper
return $url_parts['base'] . (($params) ? '?' . $this->glue_url_params($params) : '');
}
+
+ /**
+ * Get a valid page
+ *
+ * @param string $page The page to verify
+ * @param bool $mod_rewrite Whether mod_rewrite is enabled, default: false
+ *
+ * @return string A valid page based on given page and mod_rewrite
+ */
+ public function get_valid_page($page, $mod_rewrite = false)
+ {
+ // We need to be cautious here.
+ // On some situations, the redirect path is an absolute URL, sometimes a relative path
+ // For a relative path, let's prefix it with $phpbb_root_path to point to the correct location,
+ // else we use the URL directly.
+ $url_parts = parse_url($page);
+
+ // URL
+ if ($url_parts === false || empty($url_parts['scheme']) || empty($url_parts['host']))
+ {
+ // Remove 'app.php/' from the page, when rewrite is enabled.
+ // Treat app.php as a reserved file name and remove on mod rewrite
+ // even if it might not be in the phpBB root.
+ if ($mod_rewrite && ($app_position = strpos($page, 'app.' . $this->php_ext . '/')) !== false)
+ {
+ $page = substr($page, 0, $app_position) . substr($page, $app_position + strlen('app.' . $this->php_ext . '/'));
+ }
+
+ // Remove preceding slashes from page name and prepend root path
+ $page = $this->get_phpbb_root_path() . ltrim($page, '/\\');
+ }
+
+ return $page;
+ }
}
diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css
index 4768309c29..e73f8c9d54 100644
--- a/phpBB/styles/prosilver/theme/content.css
+++ b/phpBB/styles/prosilver/theme/content.css
@@ -276,6 +276,9 @@ dd.option {
.postbody img.postimage {
max-width: 100%;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
}
.search .postbody {
diff --git a/tests/path_helper/path_helper_test.php b/tests/path_helper/path_helper_test.php
index bb68f8b3bc..73f0e6bafc 100644
--- a/tests/path_helper/path_helper_test.php
+++ b/tests/path_helper/path_helper_test.php
@@ -436,4 +436,29 @@ class phpbb_path_helper_test extends phpbb_test_case
{
$this->assertEquals($this->phpbb_root_path . $expected, $this->path_helper->get_web_root_path_from_ajax_referer($referer_url, $board_url));
}
+
+ public function data_get_valid_page()
+ {
+ return array(
+ // array( current page , mod_rewrite setting , expected output )
+ array('index', true, 'index'),
+ array('index', false, 'index'),
+ array('foo/index', true, 'foo/index'),
+ array('foo/index', false, 'foo/index'),
+ array('app.php/foo', true, 'foo'),
+ array('app.php/foo', false, 'app.php/foo'),
+ array('/../app.php/foo', true, '../foo'),
+ array('/../app.php/foo', false, '../app.php/foo'),
+ array('/../example/app.php/foo/bar', true, '../example/foo/bar'),
+ array('/../example/app.php/foo/bar', false, '../example/app.php/foo/bar'),
+ );
+ }
+
+ /**
+ * @dataProvider data_get_valid_page
+ */
+ public function test_get_valid_page($page, $mod_rewrite, $expected)
+ {
+ $this->assertEquals($this->phpbb_root_path . $expected, $this->path_helper->get_valid_page($page, $mod_rewrite));
+ }
}