Fix infinite loop if quotation reach last line of the post
[banana.git] / banana / post.inc.php
index b48e8b3..1da8783 100644 (file)
@@ -209,7 +209,8 @@ class BananaPost
      */
     function _fix_charset()
     {
-        if (preg_match('!charset="?([^;"]*)"?\s*(;|$)?!', $this->headers['content-type'], $matches)) {
+        if (isset($this->headers['content-type'])
+                && preg_match('!charset="?([^;"]*)"?\s*(;|$)?!', $this->headers['content-type'], $matches)) {
             $body = iconv($matches[1], 'utf-8', $this->body);
             if (strlen($body) == 0) {
                 return false;
@@ -414,14 +415,15 @@ class BananaPost
              . makeImgLink(Array('group'  => $banana->state['group'],
                                  'action' => 'new'),
                            'post.gif',
-                           _b_('Nouveau message'))
+                           _b_('Nouveau message')) . ' '
              . makeImgLink(Array('group'  => $banana->state['group'],
                                  'artid'  => $this->id,
                                  'action' => 'new'),
                            'reply.gif',
                            _b_('RĂ©pondre'));
         if ($this->checkCancel()) {
-            $res .= makeImgLink(Array('group'  => $banana->state['group'],
+            $res .= ' '
+                  . makeImgLink(Array('group'  => $banana->state['group'],
                                       'artid'  => $this->id,
                                       'action' => 'cancel'),
                                 'cancel.gif',
@@ -470,8 +472,12 @@ class BananaPost
             $res .= '</th></tr>';
         }
  
-        preg_match("@text/([^;]+);@", $this->headers['content-type'], $format);
-        $format = $format[1];
+        if (isset($this->headers['content-type'])
+                && preg_match("@text/([^;]+);@", $this->headers['content-type'], $format)) {
+            $format = $format[1];
+        } else {
+            $format = 'plain';
+        }
         $res .= '<tr class="impair"><td colspan="2" class="body"';
         if ($format == 'html') {
             if (preg_match('@<body[^>]*bgcolor="?([#0-9a-f]+)"?[^>]*>@i', $this->body, $bgcolor)) {