E_NOTICE level warnings in php 5.0.4 and later (#1206474). [php5]
- Added extra checks in SquirrelMail charset_encode() function in case
somebody removed html to us-ascii conversion library (#1239782).
+ - Fixed invalid reference in src/download.php. E_NOTICE level warnings
+ could corrupt attachments in php 4.4.0.
+ - Added internal dgettext() and dngettext() functions.
+ - Added display of attachments on printer friendly page.
+ - Added workarounds for encoding of long multibyte headers (#1246305)
+ and sq_count8bit() function.
+ - Added custom error handling class and related functions.
Version 1.5.0 - 2 February 2004
-------------------------------
}
/**
- * Encodes header as quoted-printable
+ * Encodes header
*
- * Encode a string according to RFC 1522 for use in headers if it
- * contains 8-bit characters or anything that looks like it should
- * be encoded.
+ * Function uses XTRA_CODE _encodeheader function, if such function exists.
+ *
+ * mb_encode_mimeheader is used, if function is present, 50% or more bytes
+ * are 8bit and multibyte character set is used.
+ *
+ * Function uses Q encoding by default and encodes a string according to RFC
+ * 1522 for use in headers if it contains 8-bit characters or anything that
+ * looks like it should be encoded.
*
* @param string $string header string, that has to be encoded
* @return string quoted-printable encoded string
return call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_encodeheader', $string);
}
+ // Use B encoding for multibyte charsets
+ $mb_charsets = array('utf-8','big-5','gb2313','euc-kr');
+ if (function_exists('mb_encode_mimeheader') &&
+ in_array($default_charset,$mb_charsets) &&
+ in_array($default_charset,sq_mb_list_encodings()) &&
+ sq_count8bit($string)>=(strlen($string)/2)) {
+ return mb_encode_mimeheader($string,$default_charset,'B',"\r\n");
+ }
+
// Encode only if the string contains 8-bit characters or =?
$j = strlen($string);
$max_l = 75 - strlen($default_charset) - 7;
// use vanilla string functions as last option
return strtoupper($string);
}
+
+/**
+ * Counts 8bit bytes in string
+ * @param string $string tested string
+ * @return integer number of 8bit bytes
+ */
+function sq_count8bit($string) {
+ $count=0;
+ for ($i=0; $i<strlen($string); $i++) {
+ if (ord($string[$i]) > 127) $count++;
+ }
+ return $count;
+}
$PHP_SELF = php_self();
?>
\ No newline at end of file