Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix GH-11338: SplFileInfo empty getBasename with more than one slash
- Loading branch information
Showing
3 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--TEST-- | ||
GH-11338 (SplFileInfo empty getBasename with more than on slash) | ||
--FILE-- | ||
<?php | ||
|
||
function test($path) { | ||
echo "Testing: '$path'\n"; | ||
$file = new \SplFileInfo($path); | ||
var_dump($file->getBasename()); | ||
var_dump($file->getFilename()); | ||
} | ||
|
||
test('/dir/anotherdir/basedir//'); | ||
test('/dir/anotherdir/basedir/'); | ||
test('/dir/anotherdir/basedir'); | ||
test('/dir/anotherdir//basedir'); | ||
test('///'); | ||
test('//'); | ||
test('/'); | ||
test(''); | ||
|
||
?> | ||
--EXPECT-- | ||
Testing: '/dir/anotherdir/basedir//' | ||
string(7) "basedir" | ||
string(7) "basedir" | ||
Testing: '/dir/anotherdir/basedir/' | ||
string(7) "basedir" | ||
string(7) "basedir" | ||
Testing: '/dir/anotherdir/basedir' | ||
string(7) "basedir" | ||
string(7) "basedir" | ||
Testing: '/dir/anotherdir//basedir' | ||
string(7) "basedir" | ||
string(7) "basedir" | ||
Testing: '///' | ||
string(0) "" | ||
string(1) "/" | ||
Testing: '//' | ||
string(0) "" | ||
string(1) "/" | ||
Testing: '/' | ||
string(0) "" | ||
string(1) "/" | ||
Testing: '' | ||
string(0) "" | ||
string(0) "" |