diff options
| -rw-r--r-- | phpBB/includes/functions.php | 4 | ||||
| -rw-r--r-- | phpBB/install/install_convert.php | 2 | ||||
| -rw-r--r-- | tests/functions/is_absolute_test.php | 35 |
3 files changed, 38 insertions, 3 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 98a1dab722..4b144a20a1 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1005,7 +1005,7 @@ if (!function_exists('stripos')) */ function is_absolute($path) { - return ($path[0] == '/' || (DIRECTORY_SEPARATOR == '\\' && preg_match('#^[a-z]:[/\\\]#i', $path))) ? true : false; + return (isset($path[0]) && $path[0] == '/' || (DIRECTORY_SEPARATOR == '\\' && preg_match('#^[a-z]:[/\\\]#i', $path))) ? true : false; } /** @@ -2740,7 +2740,7 @@ function meta_refresh($time, $url, $disable_cd_check = false) // For XHTML compatibility we change back & to & $template->assign_vars(array( - 'META' => '<meta http-equiv="refresh" content="' . $time . ';url=' . $url . '" />') + 'META' => '<meta http-equiv="refresh" content="' . $time . '; url=' . $url . '" />') ); return $url; diff --git a/phpBB/install/install_convert.php b/phpBB/install/install_convert.php index 62efc3e46b..fb97255981 100644 --- a/phpBB/install/install_convert.php +++ b/phpBB/install/install_convert.php @@ -2087,7 +2087,7 @@ class install_convert extends module // Because we should not rely on correct settings, we simply use the relative path here directly. $template->assign_vars(array( 'S_REFRESH' => true, - 'META' => '<meta http-equiv="refresh" content="5;url=' . $url . '" />') + 'META' => '<meta http-equiv="refresh" content="5; url=' . $url . '" />') ); } } diff --git a/tests/functions/is_absolute_test.php b/tests/functions/is_absolute_test.php new file mode 100644 index 0000000000..5d70b6c2a3 --- /dev/null +++ b/tests/functions/is_absolute_test.php @@ -0,0 +1,35 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + +class phpbb_functions_is_absolute_test extends phpbb_test_case +{ + static public function is_absolute_data() + { + return array( + array('', false), + array('/etc/phpbb', true), + array('etc/phpbb', false), + + // Until we got DIRECTORY_SEPARATOR replaced in that function, + // test results vary on OS. + array('c:\windows', DIRECTORY_SEPARATOR == '\\'), + array('C:\Windows', DIRECTORY_SEPARATOR == '\\'), + ); + } + + /** + * @dataProvider is_absolute_data + */ + public function test_is_absolute($path, $expected) + { + $this->assertEquals($expected, is_absolute($path)); + } +} |
