=?utf-8?q?*=20Principalement=20du=20nettoyage=20de=20code
[banana.git] / banana / misc.inc.php
index 04bd09c..7520adf 100644 (file)
@@ -42,7 +42,7 @@ function textFormat_translate($format)
  */
 function removeEvilTags($source)
 {
-    $allowedTags = '<h1><b><i><a><ul><li><pre><hr><blockquote><img><br><font><p><small><big><sup><sub><code>';
+    $allowedTags = '<h1><b><i><a><ul><li><pre><hr><blockquote><img><br><font><p><small><big><sup><sub><code><em>';
     $source = strip_tags($source, $allowedTags);
     return preg_replace('/<(.*?)>/ie', "'<'.removeEvilAttributes('\\1').'>'", $source);
 }
@@ -63,8 +63,8 @@ function removeEvilAttributes($tagSource)
  */
 function htmlToPlainText($res)
 {
-    $res = trim(html_entity_decode(strip_tags($res, '<br>')));
-    $res = preg_replace("@<br[^>]>@i", "\n", $res);
+    $res = trim(html_entity_decode(strip_tags($res, '<br><p>')));
+    $res = preg_replace("@</?(br|p)[^>]*>@i", "\n", $res);
     if (!is_utf8($res)) {
         $res = utf8_encode($res);
     }   
@@ -273,7 +273,7 @@ function displayshortcuts($first = -1) {
     } else {
         $res .= "[<a href=\"?group=$group&amp;artid=$artid&amp;action=new\">"
             ._b_('RĂ©pondre')."</a>] ";
-        if ($banana->post->checkcancel()) {
+        if ($banana->post && $banana->post->checkcancel()) {
             $res .= "[<a href=\"?group=$group&amp;artid=$artid&amp;action=cancel\">"
                 ._b_('Annuler ce message')."</a>] ";
         }