Changed handle of multi-line headers,
Changed regexp for charset detect
Added check for header 'content-transfer-encoding' == 'base64'
Convert send subject with iconv_mime_encode() but PHP5 only
Added charset convert in decode_header_value()
scripts_common.inc.orig 1.36
nntp.inc.orig 1.77
<?php --- nntp.inc.orig 2009-04-14 10:46:11.000000000 +0200
+++ nntp.inc 2009-04-14 11:19:08.000000000 +0200
@@ -162,7 +162,8 @@
function format_headers()
{
/* convert to unix line endings and handle multi-line headers */
- $this->headers = str_replace(array("\r\n", "\n "), array("\n",""), $this->headers);
+ $this->headers = str_replace("\r\n","\n", $this->headers);
+ $this->headers = preg_replace("/\n(\t| )+/", ' ', $this->headers);
$hdr = explode("\n", trim($this->headers));
$this->headers = array();
@@ -402,12 +403,15 @@
}
}
- if (isset($this->headers['content-type']) && preg_match('!charset="([^"]+)"!', $this->headers['content-type'], $m)) {
+ if (isset($this->headers['content-type']) && preg_match('!charset="?([^"]+?)"?(;|\s|$)!', $this->headers['content-type'], $m)) {
$charset = $m[1];
} else {
$charset = $GLOBALS['CHARSET'];
}
- if (isset($this->headers['content-transfer-encoding']) && $this->headers['content-transfer-encoding'] == 'quoted-printable') {
+ if (isset($this->headers['content-transfer-encoding']) &&
+ ($this->headers['content-transfer-encoding'] == 'quoted-printable'
+ || $this->headers['content-transfer-encoding'] == 'base64')
+ ) {
$enc = $this->headers['content-transfer-encoding'];
} else {
$enc = '';
@@ -420,6 +424,9 @@
}
$msg_post->subject = apply_custom_replace($this->subject);
+ if ( !preg_match('!(.*?)(=\?([^?]+)\?(Q|B)\?([^?]*)\?=)[[:space:]]*([^=]*)!i', $msg_post->subject)) {
+ $msg_post->subject = decode_string($msg_post->subject,"",$charset);
+ }
$msg_post->body = decode_string($this->body, $enc, $charset);
if ( !strlen($msg_post->subject) ) {
$msg_post->subject = "(no subject)";
@@ -546,7 +553,9 @@
fputs($this->fs, "From: $from\r\n");
fputs($this->fs, "Newsgroups: $this->newsgroup\r\n");
- fputs($this->fs, "Subject: $subject\r\n");
+ fputs($this->fs, iconv_mime_encode("Subject:", $subject,
+ array('scheme'=>'Q', "input-charset"=>$GLOBALS['CHARSET'],"output-charset"=>$GLOBALS['CHARSET']))
+ ."\r\n");
if ($GLOBALS['FORUM_TITLE']) {
fputs($this->fs, "Organization: ".$GLOBALS['FORUM_TITLE']."\r\n"); ?>
<?php --- scripts_common.inc.orig 2009-04-14 11:24:09.000000000 +0200
+++ scripts_common.inc 2009-04-14 11:27:26.000000000 +0200
@@ -147,9 +147,9 @@
$ec_type = strtolower($m[4][$i]);
if ($ec_type == 'q') {
- $newval .= decode_string(str_replace('_', ' ', $m[5][$i]), 'quoted-printable');
+ $newval .= decode_string(str_replace('_', ' ', $m[5][$i]), 'quoted-printable',$m[3][$i]);
} else if ($ec_type == 'b') {
- $newval .= decode_string($m[5][$i], 'base64');
+ $newval .= decode_string($m[5][$i], 'base64',$m[3][$i]);
}
if (!empty($m[5][$i])) { ?>
|