Skip to content

Commit

Permalink
[mms] Horde_Mime::quotedPrintableEncode() is deprecated.
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Sep 29, 2014
1 parent 8b51f68 commit 84a7822
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 54 deletions.
5 changes: 5 additions & 0 deletions framework/Mime/doc/Horde/Mime/UPGRADING
Expand Up @@ -42,6 +42,11 @@ Upgrading to 2.5

This method is deprecated. Use Horde_Mime_Id#idArithmetic() instead.

- quotedPrintableEncode()

This method is deprecated. Use PHP's quoted_printable_encode() method
instead.

- uudecode()

This method is deprecated. Use the Horde_Mime_Uudecode() class instead.
Expand Down
78 changes: 24 additions & 54 deletions framework/Mime/lib/Horde/Mime.php
Expand Up @@ -127,60 +127,6 @@ static protected function _encode($text, $charset)
return $out;
}

/**
* Encodes a line via quoted-printable encoding.
*
* @param string $text The text to encode (UTF-8).
* @param string $eol The EOL sequence to use.
* @param integer $wrap Wrap a line at this many characters.
*
* @return string The quoted-printable encoded string.
*/
static public function quotedPrintableEncode($text, $eol = self::EOL,
$wrap = 76)
{
$curr_length = 0;
$output = '';

/* We need to go character by character through the data. */
for ($i = 0, $length = strlen($text); $i < $length; ++$i) {
$char = $text[$i];

/* If we have reached the end of the line, reset counters. */
if ($char == "\n") {
$output .= $eol;
$curr_length = 0;
continue;
} elseif ($char == "\r") {
continue;
}

/* Spaces or tabs at the end of the line are NOT allowed. Also,
* ASCII characters below 32 or above 126 AND 61 must be
* encoded. */
$ascii = ord($char);
if ((($ascii === 32) &&
($i + 1 != $length) &&
(($text[$i + 1] == "\n") || ($text[$i + 1] == "\r"))) ||
(($ascii < 32) || ($ascii > 126) || ($ascii === 61))) {
$char_len = 3;
$char = '=' . Horde_String::upper(sprintf('%02s', dechex($ascii)));
} else {
$char_len = 1;
}

/* Lines must be $wrap characters or less. */
$curr_length += $char_len;
if ($curr_length > $wrap) {
$output .= '=' . $eol;
$curr_length = $char_len;
}
$output .= $char;
}

return $output;
}

/**
* Decodes a MIME encoded (RFC 2047) string.
*
Expand Down Expand Up @@ -358,4 +304,28 @@ static public function isChild($base, $id)
return $id_ob->isChild($id);
}

/**
* @deprecated Use quoted_printable_encode() instead.
*/
static public function quotedPrintableEncode($text, $eol = self::EOL,
$wrap = 76)
{
$fp = fopen('php://temp', 'r+');
stream_filter_append(
$fp,
'convert.quoted-printable-encode',
STREAM_FILTER_WRITE,
array(
'line-break-chars' => self::EOL,
'line-length' => $wrap
)
);
fwrite($fp, $text);
rewind($fp);
$out = stream_get_contents($fp);
fclose($fp);

return $out;
}

}
2 changes: 2 additions & 0 deletions framework/Mime/package.xml
Expand Up @@ -28,6 +28,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Horde_Mime::quotedPrintableEncode() is deprecated.
* [mms] Moved MIME ID manipulation/query methods out of Horde_Mime and into Horde_Mime_Id.
* [mms] Use string-based ABNF-based parser for scanning MIME content parameters instead of a regular expression (Bug #13587).
* [mms] Moved content parameter handling methods out of Horde_Mime and into Horde_Mime_ContentParam.
Expand Down Expand Up @@ -1455,6 +1456,7 @@
<date>2014-09-25</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Horde_Mime::quotedPrintableEncode() is deprecated.
* [mms] Moved MIME ID manipulation/query methods out of Horde_Mime and into Horde_Mime_Id.
* [mms] Use string-based ABNF-based parser for scanning MIME content parameters instead of a regular expression (Bug #13587).
* [mms] Moved content parameter handling methods out of Horde_Mime and into Horde_Mime_ContentParam.
Expand Down

0 comments on commit 84a7822

Please sign in to comment.