From: x2003bruneau Date: Sun, 5 Mar 2006 21:20:00 +0000 (+0000) Subject: =?utf-8?q?*=20Gestion=20de=20l'encodage=20'quoted-printable'=20dans=20le=20cas=20de... X-Git-Tag: 1.8~267 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=76032c26b695305820448a33acd03e73cc502b41;p=banana.git =?utf-8?q?*=20Gestion=20de=20l'encodage=20'quoted-printable'=20dans=20le=20cas=20de=20messages=20multipart =20*=20Gestion=20de=20message=20dont=20les=20paragraphes=20sont=20d=C3=83=C2=A9limit=C3=83=C2=A9s=20par=20des=20div =20*=20Am=C3=83=C2=A9lioration=20de=20la=20gestion=20de=20l'encodage=20dans=20le=20cas=20de=20message=20html/richtext?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@28 9869982d-c50d-0410-be91-f2a2ec7c7c7b --- diff --git a/banana/misc.inc.php b/banana/misc.inc.php index 27cb940..f8df870 100644 --- a/banana/misc.inc.php +++ b/banana/misc.inc.php @@ -43,6 +43,7 @@ function textFormat_translate($format) function removeEvilTags($source) { $allowedTags = '



  • '; + $source = preg_replace('||i', '
    ', $source); $source = strip_tags($source, $allowedTags); return preg_replace('/<(.*?)>/ie', "'<'.removeEvilAttributes('\\1').'>'", $source); } @@ -63,8 +64,8 @@ function removeEvilAttributes($tagSource) */ function htmlToPlainText($res) { - $res = trim(html_entity_decode(strip_tags($res, '

    '))); - $res = preg_replace("@]*>@i", "\n", $res); + $res = trim(html_entity_decode(strip_tags($res, '


    '))); + $res = preg_replace("@]*>@i", "\n", $res); if (!is_utf8($res)) { $res = utf8_encode($res); } @@ -307,9 +308,9 @@ function wrap($text, $_prefix="") function formatbody($_text, $format='plain') { if ($format == 'html') { - $res = '
    '.removeEvilTags($_text).'
    '; + $res = '
    '.html_entity_decode(to_entities(removeEvilTags($_text))).'
    '; } else if ($format == 'richtext') { - $res = '
    '.richtextToHtml($_text).'
    '; + $res = '
    '.html_entity_decode(to_entities(richtextToHtml($_text))).'
    '; $format = 'html'; } else { $res = "\n\n" . to_entities(wrap($_text, ""))."\n\n"; diff --git a/banana/post.inc.php b/banana/post.inc.php index 20ab505..e0f3c5f 100644 --- a/banana/post.inc.php +++ b/banana/post.inc.php @@ -150,7 +150,11 @@ class BananaPost break; } } - return Array('headers' => $local_headers, 'body' => join("\n", $lines)); + $local_body = join("\n", $lines); + if (preg_match("/quoted-printable/", $local_headers['content-transfer-encoding'])) { + $local_body = quoted_printable_decode($local_body); + } + return Array('headers' => $local_headers, 'body' => $local_body); } /** add an attachment @@ -250,7 +254,7 @@ class BananaPost $this->body = iconv($matches[1], 'utf-8', $this->body); } else { $this->body = utf8_encode($this->body); - } + } return true; }