}
$i++;
break;
+ case 'u':
+ /* User-Agent */
+ if (strtolower(substr($line,0,10)) == 'user-agent') {
+ $hdr->xmailer = trim(substr($line, 10));
+ }
+ $i++;
+ break;
default:
$i++;
break;
if ($imap_server_type == 'macosx') {
foreach ($multi_search as $multi_search_part) {
+ if (strtoupper($languages[$squirrelmail_language]['CHARSET']) == 'ISO-2022-JP') {
+ $multi_search_part = mb_convert_encoding($multi_search_part, 'JIS', 'auto');
+ }
$search_string .= $search_where . ' ' .$multi_search_part . ' ';
}
}
else {
foreach ($multi_search as $multi_search_part) {
+ if (strtoupper($languages[$squirrelmail_language]['CHARSET']) == 'ISO-2022-JP') {
+ $multi_search_part = mb_convert_encoding($multi_search_part, 'JIS', 'auto');
+ }
$search_string .= $search_where . ' {' . strlen($multi_search_part)
. "}\r\n" . $multi_search_part . ' ';
}
}
function processSubject($subject) {
+ global $squirrelmail_language;
/* Shouldn't ever happen -- caught too many times in the IMAP functions */
if ($subject == '')
return _("(no subject)");
return $subject;
}
+ if ($squirrelmail_language == 'ja_JP' && function_exists('mb_strimwidth')) {
+ return mb_strimwidth($subject, 0, $trim_val, '...');
+ }
+
return substr($subject, 0, $trim_val) . '...';
}
// Don't kill the connection if the browser is over a dialup
// and it would take over 30 seconds to download it.
- // don´t call set_time_limit in safe mode.
+ // don\8e´t call set_time_limit in safe mode.
if (!ini_get("safe_mode")) {
set_time_limit(0);
}
// If there are other types that shouldn't be formatted, add
// them here
if ($body_message->header->type1 == 'html') {
+ $body = charset_decode_japanese($body);
if ( $show_html_default <> 1 ) {
$body = strip_tags( $body );
translateText($body, $wrap_at,
/** this function decodes the body depending on the encoding type. **/
function decodeBody($body, $encoding) {
+
$body = str_replace("\r\n", "\n", $body);
$encoding = strtolower($encoding);
* Patched by Christian Schmidt <christian@ostenfeld.dk> 23/03/2002
*/
function decodeHeader ($string, $utfencode=true) {
+ global $squirrelmail_language;
if (is_array($string)) {
$string = implode("\n", $string);
}
+
+ if ($squirrelmail_language == 'ja_JP' && function_exists('mb_convert_encoding')) {
+ $string = str_replace("\t", "", $string);
+ if (eregi('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=', $string))
+ $string = mb_decode_mimeheader($string);
+ return @mb_convert_encoding($string, 'EUC-JP', 'AUTO');
+ }
+
$i = 0;
while (preg_match('/^(.{' . $i . '})(.*)=\?([^?]*)\?(Q|B)\?([^?]*)\?=/Ui',
$string, $res)) {
* be encoded.
*/
function encodeHeader ($string) {
- global $default_charset;
+ global $default_charset, $squirrelmail_language;
+
+ if ($squirrelmail_language == 'ja_JP' && function_exists('mb_encode_mimeheader')) {
+ return mb_encode_mimeheader($string);
+ }
// Encode only if the string contains 8-bit characters or =?
$j = strlen( $string );
if ( isset($info['remotefilename'])
&& $info['remotefilename'] != '') {
$header .= "Content-Type: $filetype; name=\"" .
- $info['remotefilename'] . "\"$rn";
+ encodeHeader(charset_encode_japanese($info['remotefilename'])) . "\"$rn";
$header .= "Content-Disposition: attachment; filename=\""
- . $info['remotefilename'] . "\"$rn";
+ . encodeHeader(charset_encode_japanese($info['remotefilename'])) . "\"$rn";
} else {
$header .= "Content-Type: $filetype$rn";
}
}
/* Print all the needed RFC822 headers */
-function write822Header ($fp, $t, $c, $b, $subject, $more_headers, $session, $rn="\r\n") {
+function write822Header ($fp, $t, $c, $b, $subject, $body, $more_headers, $session, $rn="\r\n") {
global $REMOTE_ADDR, $SERVER_NAME, $REMOTE_PORT;
global $data_dir, $username, $popuser, $domain, $version, $useSendmail;
global $default_charset, $HTTP_VIA, $HTTP_X_FORWARDED_FOR;
$header .= mimeBoundary();
$header .= "\"$rn";
} else {
+ if (strtolower($default_charset) == 'iso-2022-jp') {
+ if (mb_detect_encoding($body) == 'ASCII') {
+ $header .= 'Content-Type: text/plain; US-ASCII' . $rn;
+ $header .= "Content-Transfer-Encoding: 8bit" . $rn;
+ } else {
+ $header .= 'Content-Type: '.$contentType . $rn;
+ $header .= "Content-Transfer-Encoding: 7bit" . $rn;
+ }
+ } else {
$header .= 'Content-Type: ' . $contentType . $rn;
$header .= "Content-Transfer-Encoding: 8bit" . $rn;
}
+ }
$header .= $rn; // One blank line to separate header and body
$headerlength = strlen($header);
$body .= "Content-Type: text/plain" . $rn;
}
- $body .= "Content-Transfer-Encoding: 8bit" . $rn . $rn;
- $body .= $passedBody . $rn . $rn;
- if ($fp) fputs ($fp, $body);
+ if (strtolower($default_charset) == 'iso-2022-jp') {
+ if (mb_detect_encoding($passedBody) == 'ASCII') {
+ $body .= "Content-Transfer-Encoding: 8bit" . $rn . $rn .
+ $passedBody . $rn . $rn;
+ } else {
+ $body .= "Content-Transfer-Encoding: 7bit\r\n\r\n" .
+ mb_convert_encoding($passedBody, 'JIS') . "\r\n\r\n";
+ }
+ } else {
+ $body .= "Content-Transfer-Encoding: 8bit" . $rn . $rn .
+ $passedBody . $rn . $rn;
+ }
+ if ($fp) {
+ fputs ($fp, $body);
+ }
$attachmentlength = attachFiles($fp, $session, $rn);
$postbody .= $rn . "--" . mimeBoundary() . "--" . $rn . $rn;
if ($fp) fputs ($fp, $postbody);
} else {
- $body = $passedBody . $rn;
- if ($fp) fputs ($fp, $body);
+ if (strtolower($default_charset) == 'iso-2022-jp') {
+ $body = mb_convert_encoding($passedBody, 'JIS') . $rn;
+ } else {
+ $body = $passedBody . $rn;
+ }
+ if ($fp) {
+ fputs ($fp, $body);
+ }
$postbody = $rn;
- if ($fp) fputs ($fp, $postbody);
+ if ($fp) {
+ fputs ($fp, $postbody);
+ }
}
return (strlen($body) + strlen($postbody) + $attachmentlength);
$fp = popen (escapeshellcmd("$sendmail_path -t -f$envelopefrom"), "w");
}
- $headerlength = write822Header ($fp, $t, $c, $b, $subject,
+ $headerlength = write822Header ($fp, $t, $c, $b, $subject, $body,
$more_headers, $session, "\n");
$bodylength = writeBody($fp, $body, $session, "\n");
/* Send the message */
$headerlength = write822Header ($smtpConnection, $t, $c, $b,
- $subject, $more_headers, $session);
+ $subject, $body, $more_headers, $session);
$bodylength = writeBody($smtpConnection, $body, $session);
fputs($smtpConnection, ".\r\n"); /* end the DATA part */
$length = $headerlength + $bodylength;
sqimap_append ($imap_stream, $sent_folder, $length);
- write822Header ($imap_stream, $t, $c, $b, $subject, $more_headers,
+ write822Header ($imap_stream, $t, $c, $b, $subject, $body, $more_headers,
$session);
writeBody ($imap_stream, $body, $session);
sqimap_append_done ($imap_stream);
'ns_4551_1' => 'ns_4551_1',
'koi8-r' => 'koi8-r',
'euc-KR' => 'euc-KR',
- 'windows-1251' => 'windows-1251' ) ),
+ 'windows-1251' => 'windows-1251'
+ 'ISO-2022-JP' => 'ISO-2022-JP' ) ),
'$data_dir' => array( 'name' => _("Data Directory"),
'type' => SMOPT_TYPE_STRING,
'size' => 40 ),
(substr(strtolower($subject), 0, 6) != '[ fwd:')) {
$subject = '[Fwd: ' . $subject . ']';
}
- $body = getforwardHeader($orig_header) . $body;
+ $body = getforwardHeader($orig_header) . charset_decode_japanese($body);
sqUnWordWrap($body);
getAttachments($message, $session, $passed_id, $entities, $imapConnection);
break;
$subject = 'Re: ' . $subject;
}
/* this corrects some wrapping/quoting problems on replies */
- $rewrap_body = explode("\n", $body);
+ $rewrap_body = explode("\n", charset_decode_japanese($body));
$body = getReplyCitation($orig_header->from->personal);
$cnt = count($rewrap_body);
for ($i=0;$i<$cnt;$i++) {
}
if ($use_signature == true && $newmail == true && !isset($from_htmladdr_search)) {
if ($sig_first == '1') {
+ if ($charset == 'iso-2022-jp') {
+ echo "\n\n".($prefix_sig==true? "-- \n":'').mb_convert_encoding($signature, 'EUC-JP');
+ } else {
echo "\n\n".($prefix_sig==true? "-- \n":'').htmlspecialchars($signature);
+ }
echo "\n\n".htmlspecialchars($body);
}
else {
echo "\n\n".htmlspecialchars($body);
+ if ($charset == 'iso-2022-jp') {
+ echo "\n\n".($prefix_sig==true? "-- \n":'').mb_convert_encoding($signature, 'EUC-JP');
+ }else{
echo "\n\n".($prefix_sig==true? "-- \n":'').htmlspecialchars($signature);
}
}
+ }
else {
echo htmlspecialchars($body);
}
* version of IE. I don't know if it works with Opera, but it should now.
*/
function DumpHeaders($type0, $type1, $filename, $force) {
- global $HTTP_USER_AGENT;
+ global $HTTP_USER_AGENT, $squirrelmail_language;
$isIE = 0;
if (strstr($HTTP_USER_AGENT, 'compatible; MSIE ') !== false &&
$isIE6 = 1;
}
+ if ($squirrelmail_language == 'ja_JP') {
+ if (strstr($HTTP_USER_AGENT, 'Windows') !== false ||
+ strstr($HTTP_USER_AGENT, 'Mac_') !== false) {
+ $filename = mb_convert_encoding($filename, 'SJIS', 'AUTO');
+ } else {
+ $filename = mb_convert_encoding($filename, 'EUC-JP', 'AUTO');
+ }
+ } else {
$filename = ereg_replace('[^-a-zA-Z0-9\.]', '_', $filename);
+ }
// A Pox on Microsoft and it's Office!
if (! $force) {
html_tag( 'table', '', 'center', '', 'cellspacing="0" cellpadding="0" border="0"' ) .
html_tag( 'tr',
html_tag( 'td', _("From").' ', 'left' ,'','valign="top"') .
- html_tag( 'td', htmlentities($from), 'left' )
+ html_tag( 'td', htmlspecialchars($from), 'left' )
) . "\n" .
html_tag( 'tr',
html_tag( 'td', _("Subject").' ', 'left','','valign="top"' ) .
- html_tag( 'td', htmlentities($subject), 'left' )
+ html_tag( 'td', htmlspecialchars($subject), 'left' )
) . "\n" .
html_tag( 'tr',
html_tag( 'td', _("Date").' ', 'left' ) .
- html_tag( 'td', htmlentities($date), 'left' )
+ html_tag( 'td', htmlspecialchars($date), 'left' )
) . "\n" .
html_tag( 'tr',
html_tag( 'td', _("To").' ', 'left','','valign="top"' ) .
- html_tag( 'td', htmlentities($to), 'left' )
+ html_tag( 'td', htmlspecialchars($to), 'left' )
) . "\n";
if ( strlen($cc) > 0 ) { /* only show CC: if it's there... */
echo html_tag( 'tr',
html_tag( 'td', _("CC").' ', 'left','','valign="top"' ) .
- html_tag( 'td', htmlentities($cc), 'left' )
+ html_tag( 'td', htmlspecialchars($cc), 'left' )
);
}
/* body */
"\r\n" .
sprintf( _("Was displayed on %s"), $now );
+ $body = charset_encode_japanese($body);
+
// part2 (RFC2298)
$original_recipient = $to;
$original_message_id = $header->message_id;
$header = $message->rfc822_header;
$env = array();
- $env[_("Subject")] = htmlspecialchars($header->subject);
+ $env[_("Subject")] = htmlspecialchars(decodeHeader($header->subject));
$from_name = $header->getAddr_s('from');
if (!$from_name) {
$from_name = $header->getAddr_s('sender');
$from_name = _("Unknown sender");
}
}
- $env[_("From")] = htmlspecialchars($from_name);
+ $env[_("From")] = htmlspecialchars(decodeHeader($from_name));
$env[_("Date")] = getLongDateString($header->date);
$env[_("To")] = formatRecipientString($header->to, "to");
$env[_("Cc")] = formatRecipientString($header->cc, "cc");
$env[_("Priority")] = getPriorityStr($header->priority);
}
if ($show_xmailer_default) {
- $env[_("Mailer")] = $header->xmailer;
+ $env[_("Mailer")] = decodeHeader($header->xmailer);
}
if ($default_use_mdn) {
if ($mdn_user_support) {