From: x2000habouzit Date: Thu, 21 Oct 2004 13:12:06 +0000 (+0000) Subject: good encoding for mail subject X-Git-Tag: xorg/old~1213 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=8ecaac80c27fdd600b2079fa2fa61a3d01ba2205;p=platal.git good encoding for mail subject --- diff --git a/htdocs/vcard.php b/htdocs/vcard.php index 0f4e940..9aebe3b 100644 --- a/htdocs/vcard.php +++ b/htdocs/vcard.php @@ -18,44 +18,12 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: vcard.php,v 1.13 2004-10-21 12:26:12 x2000habouzit Exp $ + $Id: vcard.php,v 1.14 2004-10-21 13:12:06 x2000habouzit Exp $ ***************************************************************************/ require("auto.prepend.inc.php"); new_nonhtml_page('vcard.tpl', AUTH_COOKIE); - -function quoted_printable_encode($input, $line_max = 76) { - $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); - $lines = preg_split("/(?:\r\n|\r|\n)/", $input); - $eol = "\r\n"; - $linebreak = "=0A"; - $escape = "="; - $output = ""; - - for ($j=0;$j 126) ) { // always encode "\t", which is *not* required - $h2 = floor($dec/16); $h1 = floor($dec%16); - $c = $escape.$hex["$h2"].$hex["$h1"]; - } - if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted - $output .= $newline.$escape."\n"; // soft line break; " =\r\n" is okay - $newline = " "; - } - $newline .= $c; - } // end of for - $output .= $newline; - if ($j_title); } + function title($mail_enc=false) { + $title = stripslashes($this->_title); + return $mail_enc ? "=?ISO-8859-1?Q?".quoted_printable_encode($title,200)."?=" : $title;; + } function head() { return stripslashes($this->_head); } function getArt($aid) { @@ -251,7 +254,7 @@ EOF; require_once('diogenes.mailer.inc.php'); $mailer = new DiogenesMailer("Lettre Mensuelle Polytechnique.org ", "$prenom $nom <$forlife@polytechnique.org>", - replace_accent($this->title()), + $this->title(true), $html); if($html) { $mailer->addPart('text/plain; charset=iso-8859-1', 'iso-8859-1', $this->toText($prenom,$nom,$sex)); @@ -433,5 +436,4 @@ function enriched_to_text($input,$html=false,$just=false,$indent=0,$width=68) { return $text; } } - ?> diff --git a/include/xorg.misc.inc.php b/include/xorg.misc.inc.php index 464e9f6..d7f1235 100644 --- a/include/xorg.misc.inc.php +++ b/include/xorg.misc.inc.php @@ -18,9 +18,42 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: xorg.misc.inc.php,v 1.6 2004-09-03 00:15:51 x2000bedo Exp $ + $Id: xorg.misc.inc.php,v 1.7 2004-10-21 13:12:06 x2000habouzit Exp $ ***************************************************************************/ +function quoted_printable_encode($input, $line_max = 76) { + $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); + $lines = preg_split("/(?:\r\n|\r|\n)/", $input); + $eol = "\r\n"; + $linebreak = "=0A"; + $escape = "="; + $output = ""; + + for ($j=0;$j 126) ) { // always encode "\t", which is *not* required + $h2 = floor($dec/16); $h1 = floor($dec%16); + $c = $escape.$hex["$h2"].$hex["$h1"]; + } + if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted + $output .= $newline.$escape."\n"; // soft line break; " =\r\n" is okay + $newline = " "; + } + $newline .= $c; + } // end of for + $output .= $newline; + if ($j