mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 09:14:06 +02:00
fixes multibyte filename issue with basename()
This commit is contained in:
parent
00fa2ae40c
commit
523d1bcc12
1 changed files with 17 additions and 1 deletions
|
|
@ -109,7 +109,23 @@ 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()
|
||||
*
|
||||
* @link http://php.net/manual/en/function.basename.php#121405
|
||||
*/
|
||||
protected static function mb_basename($path): string
|
||||
{
|
||||
if (preg_match('@^.*[\\\\/]([^\\\\/]+)$@s', $path, $matches)) {
|
||||
return $matches[1];
|
||||
} else if (preg_match('@^([^\\\\/]+)$@s', $path, $matches)) {
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
private function getStat($path) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue