diff options
-rw-r--r-- | _test/tests/inc/utf8_basename.test.php | 3 | ||||
-rw-r--r-- | inc/utf8.php | 8 |
2 files changed, 7 insertions, 4 deletions
diff --git a/_test/tests/inc/utf8_basename.test.php b/_test/tests/inc/utf8_basename.test.php index 1cb5b5606..62d006088 100644 --- a/_test/tests/inc/utf8_basename.test.php +++ b/_test/tests/inc/utf8_basename.test.php @@ -59,6 +59,9 @@ class utf8_basename_test extends DokuWikiTest { array('\\this\\foo\\ДокуВики.test.Вик', '.Вик', 'ДокуВики.test'), array('/this\\foo/ДокуВики.test.Вик', '.Вик', 'ДокуВики.test'), array('/this/foo\\ДокуВики.test.Вик', '.Вик', 'ДокуВики.test'), + + array('bar.test.png', '', 'bar.test.png'), + array('bar.test.png', '.png', 'bar.test'), ); foreach($data as $test){ diff --git a/inc/utf8.php b/inc/utf8.php index 227fa830a..273c344c6 100644 --- a/inc/utf8.php +++ b/inc/utf8.php @@ -92,14 +92,14 @@ if(!function_exists('utf8_basename')){ */ function utf8_basename($path, $suffix=''){ $rpos = max(strrpos($path, '/'), strrpos($path, '\\')); - $file = substr($path, $rpos+1); + if($rpos) $path = substr($path, $rpos+1); $suflen = strlen($suffix); - if($suflen && (substr($file, -$suflen) == $suffix)){ - $file = substr($file, 0, -$suflen); + if($suflen && (substr($path, -$suflen) == $suffix)){ + $path = substr($path, 0, -$suflen); } - return $file; + return $path; } } |