1 --- eventum-1.4/include/class.mime_helper.php~ 2005-01-26 00:28:42.000000000 +0200
2 +++ eventum-1.4/include/class.mime_helper.php 2005-01-26 02:24:08.000000000 +0200
5 function encodeAddress($address)
7 + $charset = APP_CHARSET;
8 $address = MIME_Helper::removeQuotes($address);
9 - $address = MIME_Helper::encode($address);
10 - return MIME_Helper::quoteSender($address);
11 + if (Mime_Helper::is8bit($address)) {
12 + // split into name and address section
13 + preg_match("/(.*)<(.*)>/", $address, $matches);
14 + $address = "=?$charset?Q?" .
15 + str_replace(' ', '_', trim(preg_replace('/([\x80-\xFF]|[\x21-\x29]|[\xFC]|[\x3F])/e', '"=" . strtoupper(dechex(ord(stripslashes("\1"))))', $matches[1]))) . "?= <" . $matches[2] . ">";
18 + return MIME_Helper::quoteSender($address);
25 + * Wraps a Quoted printable encoded address into multiple lines if string is longer then 68 characters.
27 + * @param string $string The address string to wrap.
28 + * @return string The address on multiple lines if needed.
30 + function wrapQP($string)
33 + if (strlen($string) >= $max_length) {
34 + // get charset and content
35 + preg_match("/=\?(.+)\?Q\?(.+)\?= <(.+)>/", $string, $matches);
36 + $charset = $matches[1];
37 + $address = $matches[3];
39 + $length = $max_length - (strlen($charset) + 5);
41 + // try to find a space
42 + $last_space = strrpos(substr($matches[2], 0, $length), "_");
43 + if ($last_space != false) {
44 + $length = $last_space;
47 + $return = "=?$charset?Q?" . substr($matches[2], 0, $length) . "?=\n ";
48 + $remaining_string = substr($matches[2], $length);
49 + if (strlen($remaining_string) > 0) {
50 + $return .= Mime_Helper::wrapQP("=?$charset?Q?" . $remaining_string . "?= <$address>");
52 + $return .= "<$address>";
63 + * Decodes a quoted printable encoded address and returns the string.
65 + * @param string $address The address to decode
66 + * @return string The decoded address
68 + function decodeAddress($address)
70 + if (preg_match("/=\?.+\?Q\?(.+)\?= <(.+)>/i", $address, $matches)) {
71 + return str_replace("_", ' ', quoted_printable_decode($matches[1])) . " <" . $matches[2] . ">";
79 * Determine if a string contains 8-bit characters.