diff --git a/libraries/Error.php b/libraries/Error.php index 7114d836d8..3faa5d87f4 100644 --- a/libraries/Error.php +++ b/libraries/Error.php @@ -412,39 +412,39 @@ class Error extends Message * prevent path disclosure in error message, * and make users feel safe to submit error reports * - * @param string $dest path to be shorten + * @param string $path path to be shorten * * @return string shortened path */ - public static function relPath($dest) + public static function relPath($path) { - $dest = @realpath($dest); + $dest = @realpath($path); /* Probably affected by open_basedir */ if ($dest === FALSE) { - return $dest; + return $path; } $Ahere = explode( - PATH_SEPARATOR, - realpath(__DIR__ . PATH_SEPARATOR . '..') + DIRECTORY_SEPARATOR, + realpath(__DIR__ . DIRECTORY_SEPARATOR . '..') ); - $Adest = explode(PATH_SEPARATOR, $dest); + $Adest = explode(DIRECTORY_SEPARATOR, $dest); $result = '.'; // && count ($Adest)>0 && count($Ahere)>0 ) - while (implode(PATH_SEPARATOR, $Adest) != implode(PATH_SEPARATOR, $Ahere)) { + while (implode(DIRECTORY_SEPARATOR, $Adest) != implode(DIRECTORY_SEPARATOR, $Ahere)) { if (count($Ahere) > count($Adest)) { array_pop($Ahere); - $result .= PATH_SEPARATOR . '..'; + $result .= DIRECTORY_SEPARATOR . '..'; } else { array_pop($Adest); } } - $path = $result . str_replace(implode(PATH_SEPARATOR, $Adest), '', $dest); + $path = $result . str_replace(implode(DIRECTORY_SEPARATOR, $Adest), '', $dest); return str_replace( - PATH_SEPARATOR . PATH_SEPARATOR, - PATH_SEPARATOR, + DIRECTORY_SEPARATOR . PATH_SEPARATOR, + DIRECTORY_SEPARATOR, $path ); } diff --git a/libraries/php-gettext/gettext.inc b/libraries/php-gettext/gettext.inc index 75e2112182..908180d239 100644 --- a/libraries/php-gettext/gettext.inc +++ b/libraries/php-gettext/gettext.inc @@ -244,7 +244,7 @@ function _setlocale($category, $locale) { function _bindtextdomain($domain, $path) { global $text_domains; // ensure $path ends with a slash ('/' should work for both, but lets still play nice) - if (PATH_SEPARATOR == '\\') { + if (DIRECTORY_SEPARATOR == '\\') { if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/') $path .= '\\'; } else { diff --git a/test/classes/ErrorTest.php b/test/classes/ErrorTest.php index 5afbf66c91..caf5df9f43 100644 --- a/test/classes/ErrorTest.php +++ b/test/classes/ErrorTest.php @@ -81,15 +81,26 @@ class ErrorTest extends PMATestCase * Test for setFile * * @return void + * + * @dataProvider filePathProvider */ - public function testSetFile() + public function testSetFile($file, $expected) { - $this->object->setFile('./pma.txt'); - $this->assertStringStartsWith( - implode( - DIRECTORY_SEPARATOR, - array('.', '..', '..') - ), $this->object->getFile() + $this->object->setFile($file); + $this->assertEquals($expected, $this->object->getFile()); + } + + /** + * Data provider for setFile + * + * @return array + */ + public function filePathProvider() + { + return array( + array('./ChangeLog', './ChangeLog'), + array(__FILE__, './test/classes/PMA_Error_test.php'), + array('./NONEXISTING', './NONEXISTING'), ); }