Author: Frederik Holljen
Date: 2006-09-23 13:18:39 +0200 (Sat, 23 Sep 2006)
New Revision: 3546
Log:
- Fixed bug #9048: [ezcMail] ezcMailText does not encode properly
Modified:
trunk/Mail/ChangeLog
trunk/Mail/src/parts/text.php
trunk/Mail/tests/parts/text_part_test.php
Modified: trunk/Mail/ChangeLog
===================================================================
--- trunk/Mail/ChangeLog 2006-09-23 06:01:56 UTC (rev 3545)
+++ trunk/Mail/ChangeLog 2006-09-23 11:18:39 UTC (rev 3546)
@@ -11,8 +11,9 @@
class and its derives.
- Fixed bug #8990: ezcMail->messageID should be named ezcMail->messageId
- Added a new class (ezcMailVirtualFile) to allow attachments from memory.
+- Fixed bug #9048: [ezcMail] ezcMailText does not encode properly
+
-
1.1.2 - Monday 28 August 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Modified: trunk/Mail/src/parts/text.php
===================================================================
--- trunk/Mail/src/parts/text.php 2006-09-23 06:01:56 UTC (rev 3545)
+++ trunk/Mail/src/parts/text.php 2006-09-23 11:18:39 UTC (rev 3546)
@@ -161,8 +161,23 @@
*/
public function generateBody()
{
- // convert linebreaks to the correct type.
- return preg_replace( "/\r\n|\r|\n/", ezcMailTools::lineBreak(),
$this->text );
+ switch( $this->encoding )
+ {
+ case ezcMail::BASE64:
+ // leaves a \r\n to much at the end, but since it is base64 it
will decode
+ // properly so we just leave it
+ return chunk_split( base64_encode( $this->text ), 76,
ezcMailTools::lineBreak() );
+ break;
+ case ezcMail::QUOTED_PRINTABLE:
+ $text = preg_replace( '/[^\x21-\x3C\x3E-\x7E\x09\x20]/e',
+ 'sprintf( "=%02X", ord ( "$0" ) ) ;',
$this->text );
+ preg_match_all( '/.{1,73}([^=]{0,2})?/', $text, $match );
+ $text = implode( '=' . ezcMailTools::lineBreak(), $match[0] );
+ return $text;
+ break;
+ default:
+ return preg_replace( "/\r\n|\r|\n/",
ezcMailTools::lineBreak(), $this->text );
+ }
}
}
?>
Modified: trunk/Mail/tests/parts/text_part_test.php
===================================================================
--- trunk/Mail/tests/parts/text_part_test.php 2006-09-23 06:01:56 UTC (rev
3545)
+++ trunk/Mail/tests/parts/text_part_test.php 2006-09-23 11:18:39 UTC (rev
3546)
@@ -89,9 +89,29 @@
$this->assertEquals( 'new dummy', $temp->text );
}
+ public function testBase64Encode()
+ {
+ $reference = "Content-Type: text/plain; charset=us-ascii" .
ezcMailTools::lineBreak() .
+ "Content-Transfer-Encoding: base64" . ezcMailTools::lineBreak()
.ezcMailTools::lineBreak() .
+ "SGVyZSBpcyBzb21lIHRleHQ=" . ezcMailTools::lineBreak();
+ $text = new ezcMailText( "Here is some text", "us-ascii",
ezcMail::BASE64 );
+ $this->assertEquals( $reference, $text->generate() );
+ }
+
+ public function testQuotedPrintableEncode()
+ {
+ $reference = "Content-Type: text/plain; charset=iso-8859-1" .
ezcMailTools::lineBreak() .
+ "Content-Transfer-Encoding: quoted_printable" .
ezcMailTools::lineBreak() . ezcMailTools::lineBreak() .
+ "=E6=F8=E5=0A=F8=E6=E5";
+
+ $text = new ezcMailText( "æøå\nøæå", "iso-8859-1",
ezcMail::QUOTED_PRINTABLE );
+ $this->assertEquals( $reference, $text->generate() );
+ }
+
public static function suite()
{
return new ezcTestSuite( "ezcMailTextTest" );
}
}
?>
+q
\ No newline at end of file
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components