123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
-
-
-
-
-
- class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder
- implements Swift_Mime_ContentEncoder
- {
-
-
-
- public function __construct(Swift_CharacterStream $charStream,
- Swift_StreamFilter $filter = null, $dotEscape=false)
- {
- parent::__construct($charStream, $filter);
- if ($dotEscape) {
-
- unset($this->_safeMap[0x2e]);
- }
- }
-
-
-
- public function encodeByteStream(
- Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0,
- $maxLineLength = 0)
- {
- if ($maxLineLength > 76 || $maxLineLength <= 0)
- {
- $maxLineLength = 76;
- }
-
- $thisLineLength = $maxLineLength - $firstLineOffset;
-
- $this->_charStream->flushContents();
- $this->_charStream->importByteStream($os);
-
- $currentLine = '';
- $prepend = '';
- $size=$lineLen=0;
-
- while (false !== $bytes = $this->_nextSequence())
- {
-
- if (isset($this->_filter))
- {
-
- while ($this->_filter->shouldBuffer($bytes))
- {
-
- if (false === $moreBytes = $this->_nextSequence(1))
- {
- break;
- }
-
- foreach ($moreBytes as $b)
- {
- $bytes[] = $b;
- }
- }
-
- $bytes = $this->_filter->filter($bytes);
- }
-
- $enc = $this->_encodeByteSequence($bytes, $size);
- if ($currentLine && $lineLen+$size >= $thisLineLength)
- {
- $is->write($prepend . $this->_standardize($currentLine));
- $currentLine = '';
- $prepend = "=\r\n";
- $thisLineLength = $maxLineLength;
- $lineLen=0;
- }
- $lineLen+=$size;
- $currentLine .= $enc;
- }
- if (strlen($currentLine))
- {
- $is->write($prepend . $this->_standardize($currentLine));
- }
- }
-
-
-
- public function getName()
- {
- return 'quoted-printable';
- }
-
- }
|