Merge pull request #74 from raffis/master

Fixes multibyte issue with basename()
This commit is contained in:
Robin Appelman 2018-11-13 18:03:36 +01:00 committed by GitHub
commit 20da159fe4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -109,7 +109,24 @@ class NativeShare extends AbstractShare {
* @return \Icewind\SMB\IFileInfo
*/
public function stat($path) {
return new NativeFileInfo($this, $path, basename($path), $this->getStat($path));
return new NativeFileInfo($this, $path, self::mb_basename($path), $this->getStat($path));
}
/**
* Multibyte unicode safe version of basename()
*
* @param string $path
* @link http://php.net/manual/en/function.basename.php#121405
* @return string
*/
protected static function mb_basename($path) {
if (preg_match('@^.*[\\\\/]([^\\\\/]+)$@s', $path, $matches)) {
return $matches[1];
} elseif (preg_match('@^([^\\\\/]+)$@s', $path, $matches)) {
return $matches[1];
}
return '';
}
private function getStat($path) {