FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Bug Reports » nntp charset problems
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
nntp charset problems [message #158908] Tue, 14 April 2009 09:33 Go to previous message
webmaster_at_naszojciec is currently offline  webmaster_at_naszojciec   Poland
Messages: 4
Registered: April 2009
Karma:
Junior Member
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,+162,@@
        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,+424,@@
                        }

                        
$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,+553,@@

                
fputs($this->fs"From: $from\r\n");
                
fputs($this->fs"Newsgroups: $this->newsgroup\r\n");
-               
fputs($this->fs"Subject: $subject\r\n");
+               
fputs($this->fsiconv_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,+147,@@
                        
$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])) {
?>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: HELP! Cannot login with exact username and password
Next Topic: Fud API Error
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 23:50:52 GMT 2024

Total time taken to generate the page: 0.04182 seconds