should fix the encoding problem and bug 353 for good
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Wed, 19 Oct 2005 17:23:53 +0000 (17:23 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 4 Jan 2008 23:34:28 +0000 (00:34 +0100)
git-archimport-id: opensource@polytechnique.org--2005/banana--mainline--1.0--patch-30

banana/banana.inc.php.in
banana/misc.inc.php

index b188c52..1a8fe03 100644 (file)
@@ -262,9 +262,9 @@ class Banana
         
         $this->_newSpool($group, $this->profile['display'], $this->profile['lastnews']);
         $body = preg_replace("/\n\.[ \t\r]*\n/m", "\n..\n", $_POST['body']);
-        $msg  = 'From: '.$this->profile['name']."\n"
+        $msg  = 'From: '.headerEncode($this->profile['name'])."\n"
               . "Newsgroups: ".$_POST['newsgroups']."\n"
-              . "Subject: ".$_POST['subject']."\n"
+              . "Subject: ".headerEncode($_POST['subject'], 128)."\n"
               . (empty($this->profile['org']) ? '' : "Organization: {$this->profile['org']}\n")
               . (empty($_POST['followup'])    ? '' : 'Followup-To: '.$_POST['followup']."\n");
 
index e9f7c94..936414c 100644 (file)
@@ -35,6 +35,13 @@ function headerDecode($value) {
     return preg_replace('/=\?([^?]*)\?([BQ])\?([^?]*)\?=/e', '_headerdecode("\1", "\2", "\3")', $val);
 }
 
+function headerEncode($value, $trim = 0) {
+    if ($trim) {
+        $value = substr($value, $trim) . "[...]";
+    }
+    return "=?UTF-8?B?".base64_encode($value)."?=";
+}
+
 function header_translate($hdr) {
     switch ($hdr) {
         case 'from':            return _b_('De');