Skip to content

Commit

Permalink
encodeQuotedPrintable(): increase line length not to overrun in buffer.
Browse files Browse the repository at this point in the history
Warning: iconv_mime_encode() [function.iconv-mime-encode]: Buffer length exceeded

it happened because we specified line length smaller (=16) than the resulting
string would be (=27).
  • Loading branch information
glensc committed Dec 9, 2010
1 parent a2abf7c commit b09c887
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/eventum/class.mime_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,16 @@ function decodeAddress($address)
public static function encodeQuotedPrintable($string)
{
if (function_exists('iconv_mime_encode')) {
// avoid any wrapping by specifying line length long enough
// "test" -> 4
// ": =?ISO-8859-1?B?dGVzdA==?=" -> 27
// 3 +2 +10 +3 +7 + 3
$line_length = strlen($string) * 4 + strlen(APP_CHARSET) + 11;

$params = array(
"input-charset" => APP_CHARSET,
"output-charset" => APP_CHARSET,
// avoid any wrapping
"line-length" => strlen($string) * 4,
"line-length" => $line_length,
);
$string = iconv_mime_encode("", $string, $params);
return substr($string, 2);
Expand Down

0 comments on commit b09c887

Please sign in to comment.