new tests wrt encodings
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Tue, 24 May 2005 10:48:52 +0000 (10:48 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 4 Jan 2008 23:34:27 +0000 (00:34 +0100)
git-archimport-id: opensource@polytechnique.org--2005/banana--mainline--1.0--patch-24

banana/banana.inc.php.in
banana/misc.inc.php
banana/post.inc.php
po/banana.pot

index 081c6cd..287bb66 100644 (file)
@@ -228,7 +228,7 @@ class Banana
 
         $cuts  = displayshortcuts();
         $html  = '<h1>'._b_('Nouveau message').'</h1>'.$cuts;
-        $html .= '<form action="?group='.$group.'" method="post" accept-charset="utf8">';
+        $html .= '<form action="?group='.$group.'" method="post" accept-charset="utf-8">';
         $html .= '<table class="bicol" cellpadding="0" cellspacing="0">';
         $html .= '<tr><th colspan="2">'._b_('En-têtes').'</th></tr>';
         $html .= '<tr><td>'._b_('Nom').'</td><td>'.htmlentities($this->profile['name']).'</td></tr>';
@@ -238,7 +238,7 @@ class Banana
         $html .= '<tr><td>'._b_('Organisation').'</td><td>'.$this->profile['org'].'</td></tr>';
         $html .= '<tr><th colspan="2">'._b_('Corps').'</th></tr>';
         $html .= '<tr><td colspan="2"><textarea name="body" cols="74" rows="16">'
-            .$body.($this->profile['sig'] ? "\n\n-- \n".htmlentities($this->profile['sig']) : '').'</textarea></td></th>';
+            .to_entities($body).($this->profile['sig'] ? "\n\n-- \n".htmlentities($this->profile['sig']) : '').'</textarea></td></th>';
         $html .= '<tr><td colspan="2">';
         if ($id > 0) {
             $html .= '<input type="hidden" name="artid" value="'.$id.'" />';
index 41a37ba..9510b14 100644 (file)
@@ -13,9 +13,9 @@
 
 function _b_($str) { return utf8_decode(dgettext('banana', utf8_encode($str))); }
 
-function to_html($str, $charset) {
+function to_entities($str) {
     require_once 'banana/utf8.php';
-    return utf8entities(htmlentities(iconv($charset, 'utf8', $str), ENT_NOQUOTES, 'UTF-8'));
+    return utf8entities(htmlentities($str, ENT_NOQUOTES, 'UTF-8'));
 }
 
 /********************************************************************************
@@ -206,7 +206,7 @@ function wrap($text, $_prefix="")
 }
 
 function formatbody($_text) {
-    $res  = "\n\n" . wrap($_text, "")."\n\n";
+    $res  = "\n\n" . to_entities(wrap($_text, ""))."\n\n";
     $res  = preg_replace("/(&lt;|&gt;|&quot;)/", " \\1 ", $res);
     $res  = preg_replace('/(["\[])?((https?|ftp|news):\/\/[a-z@0-9.~%$£µ&i#\-+=_\/\?]*)(["\]])?/i', "\\1<a href=\"\\2\">\\2</a>\\4", $res);
     $res  = preg_replace("/ (&lt;|&gt;|&quot;) /", "\\1", $res);
index 60f2986..ae71489 100644 (file)
@@ -44,8 +44,7 @@ class BananaPost
         }
 
         if (preg_match('!charset=([^;]*)\s*(;|$)!', $this->headers['content-type'], $matches)) {
-            require_once 'banana/misc.inc.php';
-            $this->body = to_html($this->body, $matches[1]);
+            $this->body = iconv($matches[1], 'utf-8', $this->body)
         }
     }
 
index 79ffa3e..7cd3e86 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2005-05-24 10:50+0200\n"
+"POT-Creation-Date: 2005-05-24 12:48+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"