Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of ssh://git.zendframework.com:21652/zf
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralph Schindler committed Oct 17, 2011
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Decode.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,6 @@ public static function splitHeaderField($field, $wantedPart = null, $firstName =
*/
public static function decodeQuotedPrintable($string)
{
return iconv_mime_decode($string, ICONV_MIME_DECODE_CONTINUE_ON_ERROR);
return quoted_printable_decode($string);
}
}
13 changes: 13 additions & 0 deletions src/Part.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,19 @@ public function getContent($EOL = Mime::LINEEND)
}
}

/**
* Get the RAW unencoded content from this part
* @return string
*/
public function getRawContent()
{
if ($this->_isStream) {
return stream_get_contents($this->_content);
} else {
return $this->_content;
}
}

/**
* Create and return the array of headers for this MIME part
*
Expand Down
22 changes: 15 additions & 7 deletions test/PartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ class PartTest extends \PHPUnit_Framework_TestCase
*
* @var Zend_Mime_Part
*/
protected $_part = null;
protected $_testText;
protected $part = null;
protected $testText;

protected function setUp()
{
$this->_testText = 'safdsafsa�lg ��gd�� sd�jg�sdjg�ld�gksd�gj�sdfg�dsj�gjsd�gj�dfsjg�dsfj�djs�g kjhdkj '
$this->testText = 'safdsafsa�lg ��gd�� sd�jg�sdjg�ld�gksd�gj�sdfg�dsj�gjsd�gj�dfsjg�dsfj�djs�g kjhdkj '
. 'fgaskjfdh gksjhgjkdh gjhfsdghdhgksdjhg';
$this->part = new Mime\Part($this->_testText);
$this->part = new Mime\Part($this->testText);
$this->part->encoding = Mime\Mime::ENCODING_BASE64;
$this->part->type = "text/plain";
$this->part->filename = 'test.txt';
Expand Down Expand Up @@ -76,15 +76,15 @@ public function testContentEncoding()
{
// Test with base64 encoding
$content = $this->part->getContent();
$this->assertEquals($this->_testText, base64_decode($content));
$this->assertEquals($this->testText, base64_decode($content));
// Test with quotedPrintable Encoding:
$this->part->encoding = Mime\Mime::ENCODING_QUOTEDPRINTABLE;
$content = $this->part->getContent();
$this->assertEquals($this->_testText, quoted_printable_decode($content));
$this->assertEquals($this->testText, quoted_printable_decode($content));
// Test with 8Bit encoding
$this->part->encoding = Mime\Mime::ENCODING_8BIT;
$content = $this->part->getContent();
$this->assertEquals($this->_testText, $content);
$this->assertEquals($this->testText, $content);
}

public function testStreamEncoding()
Expand Down Expand Up @@ -114,4 +114,12 @@ public function testStreamEncoding()
fclose($fp);
$this->assertEquals(quoted_printable_decode($encoded),$original);
}

/**
* @group ZF-1491
*/
public function testGetRawContentFromPart()
{
$this->assertEquals($this->testText, $this->part->getRawContent());
}
}

0 comments on commit 8eb23ea

Please sign in to comment.