Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 2 tests for attachment name handing in parser/parts/file_parser.php #81

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: from smtp.ez.no (blackboy.ez.no [194.248.150.22])
by mta1.ez.no (Postfix) with ESMTP id 99508362508
for <[email protected]>; Fri, 23 Nov 2007 13:29:23 +0100 (CET)
Received: from [10.0.2.184] (popeye.ez.no [85.19.74.66])
by smtp.ez.no (Postfix) with ESMTP id D611AAB54C
for <[email protected]>; Fri, 23 Nov 2007 13:26:40 +0100 (CET)
Message-ID: <[email protected]>
Date: Fri, 23 Nov 2007 13:30:14 +0100
From: Alexandru Stanoi <[email protected]>
User-Agent: Thunderbird 1.5.0.12 (X11/20070604)
MIME-Version: 1.0
To: Alexandru Stanoi <[email protected]>
Subject: TEST: HTML attachment
Content-Type: multipart/mixed;
boundary="1234567890"


--1234567890
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 7bit

<html>
<body marginwidth="0" marginheight="0" leftmargin="0" topmargin="0"
bgcolor="#FFFFFF">
<table border="0" width="640" cellspacing="0" cellpadding="0"><tr><td>
<img src="cid:cam_data/photo067" alt="cam_data/photo067.jpg"><br><br>
</td></tr></table>
</body></html>

--1234567890
Content-Type: image/jpeg; name=""
Content-Transfer-Encoding: base64
Content-ID: <cam_data/photo067>
Content-Disposition: attachment; filename=" "

/9j/4AAQSkZJRgABAgEAkACQAAD/
2wCEAAwICQoJBwwKCQoNDAwOER0TERAQESQZGxUdKiUsLCkl
KSgvNEM5LzE/
MigpOk87P0VHS0xLLThSWFFJV0NJS0gBDA0NEQ8RIhMTIkgwKTBISEhISEhISEhI
SEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISP/
AABEIAPABQAMBIQACEQED
EQH/3QAEABT/
xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAAB
fQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5
OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeo
qaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/
j5+gEAAwEBAQEB
AQEBAQAAAAAAAAECAwQFBgcICQoLEQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIy
gQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNk
ZWZnaG

--1234567890--
55 changes: 55 additions & 0 deletions tests/parser/data/various/attachment_with_long_filename.mail
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: from smtp.ez.no (blackboy.ez.no [194.248.150.22])
by mta1.ez.no (Postfix) with ESMTP id 99508362508
for <[email protected]>; Fri, 23 Nov 2007 13:29:23 +0100 (CET)
Received: from [10.0.2.184] (popeye.ez.no [85.19.74.66])
by smtp.ez.no (Postfix) with ESMTP id D611AAB54C
for <[email protected]>; Fri, 23 Nov 2007 13:26:40 +0100 (CET)
Message-ID: <[email protected]>
Date: Fri, 23 Nov 2007 13:30:14 +0100
From: Alexandru Stanoi <[email protected]>
User-Agent: Thunderbird 1.5.0.12 (X11/20070604)
MIME-Version: 1.0
To: Alexandru Stanoi <[email protected]>
Subject: TEST: HTML attachment
Content-Type: multipart/mixed;
boundary="1234567890"


--1234567890
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 7bit

<html>
<body marginwidth="0" marginheight="0" leftmargin="0" topmargin="0"
bgcolor="#FFFFFF">
<table border="0" width="640" cellspacing="0" cellpadding="0"><tr><td>
<img src="cid:cam_data/photo067" alt="cam_data/photo067.jpg"><br><br>
</td></tr></table>
</body></html>

--1234567890
Content-Type: image/jpeg; name=""
Content-Transfer-Encoding: base64
Content-ID: <cam_data/photo067>
Content-Disposition: attachment; filename="SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_SOMETHINGVERYLONG_.jpg"

/9j/4AAQSkZJRgABAgEAkACQAAD/
2wCEAAwICQoJBwwKCQoNDAwOER0TERAQESQZGxUdKiUsLCkl
KSgvNEM5LzE/
MigpOk87P0VHS0xLLThSWFFJV0NJS0gBDA0NEQ8RIhMTIkgwKTBISEhISEhISEhI
SEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISP/
AABEIAPABQAMBIQACEQED
EQH/3QAEABT/
xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAAB
fQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5
OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeo
qaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/
j5+gEAAwEBAQEB
AQEBAQAAAAAAAAECAwQFBgcICQoLEQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIy
gQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNk
ZWZnaG

--1234567890--
20 changes: 20 additions & 0 deletions tests/parser/parser_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,26 @@ public function testVarious11()
$parts[1]->contentDisposition->fileName, "Fails until I figure out what the RFC means." );
}

public function testVarious12()
{
$parser = new ezcMailParser();
$set = new SingleFileSet( 'various/attachment_with_long_filename.mail' );
$mail = $parser->parseMail( $set );
$this->assertEquals( 1, count( $mail ) );
$parts = $mail[0]->body->getParts();
$this->assertEquals( true, $parts[1] instanceof ezcMailFile );
}

public function testVarious13()
{
$parser = new ezcMailParser();
$set = new SingleFileSet( 'various/attachment_only_horizontal_tab_in_filename.mail' );
$mail = $parser->parseMail( $set );
$this->assertEquals( 1, count( $mail ) );
$parts = $mail[0]->body->getParts();
$this->assertEquals( true, $parts[1] instanceof ezcMailFile );
}

public function testExtendedMailClass()
{
$parser = new ezcMailParser();
Expand Down