really fix escaping
[banana.git] / banana / banana.inc.php.in
index 287bb66..3b4e5d9 100644 (file)
@@ -218,8 +218,8 @@ class Banana
             $this->nntp->group($group);
             $this->_newPost($id);
             if ($this->post) {
-                $subject = preg_replace("/^re\s*:\s*/i", 'Re: ', $this->post->headers['subject']);
-                $body    = $this->post->name." "._b_("a écrit")." :\n".wrap($this->post->body, "> ");
+                $subject = preg_replace("/^re\s*:\s*/i", 'Re: ', 'Re: '.$this->post->headers['subject']);
+                $body    = utf8_encode($this->post->name." "._b_("a écrit"))." :\n".wrap($this->post->body, "> ");
                 $target  = isset($this->post->headers['followup-to']) ? $this->post->headers['followup-to'] : $this->post->headers['newsgroups'];
             }
         }
@@ -252,11 +252,19 @@ class Banana
 
     function action_doFup($group, $artid = -1)
     {
+        if ( ! ( is_utf8($_POST['subject']) && is_utf8($_POST['name'])
+                 && is_utf8($_POST['org']) && is_utf8($_POST['body']) )
+        ) {
+            foreach(array('subject', 'name', 'org', 'body') as $key) {
+                $_POST[$key] = utf8_encode($_POST[$key]);
+            }
+        }
+        
         $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"
               . "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");