forked from Webklex/php-imap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Attachment::decodeName remove .. from file name
If attached file has name like test..xml, then dots remove and broke file extension.
- Loading branch information
Showing
2 changed files
with
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests; | ||
|
||
use Tests\fixtures\FixtureTestCase; | ||
use Webklex\PHPIMAP\Attachment; | ||
|
||
class AttachmentTest extends FixtureTestCase | ||
{ | ||
protected Attachment $attachment; | ||
|
||
public function setUp(): void | ||
{ | ||
$message = $this->getFixture("attachment_encoded_filename.eml"); | ||
$this->attachment = $message->getAttachments()->first(); | ||
} | ||
/** | ||
* @dataProvider decodeNameDataProvider | ||
*/ | ||
public function testDecodeName(string $input, string $output): void | ||
{ | ||
$name = $this->attachment->decodeName($input); | ||
$this->assertEquals($output, $name); | ||
} | ||
|
||
public function decodeNameDataProvider(): array | ||
{ | ||
return [ | ||
['../../../../../../../../../../../var/www/shell.php', '.varwwwshell.php'], | ||
['test..xml', 'test.xml'], | ||
[chr(0), ''], | ||
['C:\\file.txt', 'Cfile.txt'], | ||
]; | ||
} | ||
} |