[evolvis-commits] r7018: [#969] fix eMail encoding↵
mirabilos at evolvis.org
mirabilos at evolvis.org
Fri Sep 24 15:03:10 CEST 2010
Author: mirabilos
Date: 2010-09-24 15:03:10 +0200 (Fri, 24 Sep 2010)
New Revision: 7018
Modified:
trunk/gforge_base/evolvisforge/gforge/common/include/utils.php
trunk/gforge_base/evolvisforge/gforge/debian/changelog
trunk/gforge_base/evolvisforge/gforge/translations/de.po
Log:
[#969] fix eMail encoding
Modified: trunk/gforge_base/evolvisforge/gforge/common/include/utils.php
===================================================================
--- trunk/gforge_base/evolvisforge/gforge/common/include/utils.php 2010-09-24 12:09:56 UTC (rev 7017)
+++ trunk/gforge_base/evolvisforge/gforge/common/include/utils.php 2010-09-24 13:03:10 UTC (rev 7018)
@@ -95,12 +95,8 @@
if (!$from) {
$from='noreply@'.$GLOBALS['sys_default_domain'];
}
-
- $charset = _('UTF-8');
- if (!$charset) {
- $charset = 'UTF-8';
- }
+ $charset = "UTF-8";
$body2 = '';
if ($extra_headers) {
@@ -115,11 +111,13 @@
$body2 .= "\nBCC: $BCC";
}
$send_html_email?$type="html":$type="plain";
+
$body2 .= "\n".util_encode_mimeheader("Subject", $subject, $charset).
- "\nContent-type: text/$type; charset=$charset".
+ "\nContent-Type: text/".$type.'; charset="'.$charset.'"'.
+ "\nContent-Transfer-Encoding: quoted-printable".
"\n\n".
- util_convert_body($body, $charset);
-
+ quoted_printable_encode(util_convert_body($body, $charset));
+
if (!$sys_sendmail_path){
$sys_sendmail_path="/usr/sbin/sendmail";
}
@@ -1007,6 +1005,103 @@
}
}
+if (!function_exists('quoted_printable_encode')) {
+ /* from http://www.php.net/manual/en/function.quoted-printable-encode.php */
+ function quoted_printable_encode($input, $line_max=75) {
+ $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);
+ /* this was wrong, fixed --mirabilos */
+ $linebreak = "\r\n";
+ /*
+ * the linebreak also counts as characters in the
+ * mime_qp_long_line rule of spam-assassin
+ */
+ $line_max = $line_max - strlen($linebreak);
+ $escape = "=";
+ $output = "";
+ $cur_conv_line = "";
+ $length = 0;
+ $whitespace_pos = 0;
+ $addtl_chars = 0;
+
+ // iterate lines
+ for ($j=0; $j<count($lines); $j++) {
+ $line = $lines[$j];
+ $linlen = strlen($line);
+
+ // iterate chars
+ for ($i = 0; $i < $linlen; $i++) {
+ $c = substr($line, $i, 1);
+ $dec = ord($c);
+
+ $length++;
+
+ if ($dec == 32) {
+ // space occurring at end of line, need to encode
+ if (($i == ($linlen - 1))) {
+ $c = "=20";
+ $length += 2;
+ }
+
+ $addtl_chars = 0;
+ $whitespace_pos = $i;
+ } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) {
+ $h2 = floor($dec/16); $h1 = floor($dec%16);
+ $c = $escape . $hex["$h2"] . $hex["$h1"];
+ $length += 2;
+ $addtl_chars += 2;
+ }
+
+ // length for wordwrap exceeded, get a newline into the text
+ if ($length >= $line_max) {
+ $cur_conv_line .= $c;
+
+ // read only up to the whitespace for the current line
+ $whitesp_diff = $i - $whitespace_pos + $addtl_chars;
+
+ /*
+ * the text after the whitespace will have to
+ * be read again ( + any additional characters
+ * that came into existence as a result of the
+ * encoding process after the whitespace)
+ *
+ * Also, do not start at 0, if there was *no*
+ * whitespace in the whole line
+ */
+ if (($i + $addtl_chars) > $whitesp_diff) {
+ $output .= substr($cur_conv_line, 0,
+ (strlen($cur_conv_line) - $whitesp_diff)) .
+ $linebreak;
+ $i = $i - $whitesp_diff + $addtl_chars;
+ } else {
+ /* emit continuation --mirabilos */
+ $output .= $cur_conv_line .
+ '=' . $linebreak;
+ }
+
+ $cur_conv_line = "";
+ $length = 0;
+ $whitespace_pos = 0;
+ } else {
+ // length for wordwrap not reached, continue reading
+ $cur_conv_line .= $c;
+ }
+ } // end of for
+
+ $length = 0;
+ $whitespace_pos = 0;
+ $output .= $cur_conv_line;
+ $cur_conv_line = "";
+
+ if ($j<=count($lines)-1) {
+ $output .= $linebreak;
+ }
+ } // end for
+
+ return trim($output);
+ }
+}
+
/*-
* I have absolutely no idea how to write a programming language, I just
* kept adding the next logical step on the way.
Modified: trunk/gforge_base/evolvisforge/gforge/debian/changelog
===================================================================
--- trunk/gforge_base/evolvisforge/gforge/debian/changelog 2010-09-24 12:09:56 UTC (rev 7017)
+++ trunk/gforge_base/evolvisforge/gforge/debian/changelog 2010-09-24 13:03:10 UTC (rev 7018)
@@ -6,8 +6,11 @@
* Deliver correct HTTP Status codes (e.g. download.php’s 404)
* When sending a 404, add some descriptive text
* gf-p-mw theming: add some styles from old Evolvis Wiki
+ * Disable broken Repository selection in ViewVC [#971]
+ * Fix XHTML bugs in German translation
+ * QP-encode sent-out eMails and fix headers [#969]
- -- Thorsten Glaser <t.glaser at tarent.de> Fri, 24 Sep 2010 11:15:19 +0200
+ -- Thorsten Glaser <t.glaser at tarent.de> Fri, 24 Sep 2010 15:01:50 +0200
gforge (4.8.3+evolvis25) unstable; urgency=low
Modified: trunk/gforge_base/evolvisforge/gforge/translations/de.po
===================================================================
--- trunk/gforge_base/evolvisforge/gforge/translations/de.po 2010-09-24 12:09:56 UTC (rev 7017)
+++ trunk/gforge_base/evolvisforge/gforge/translations/de.po 2010-09-24 13:03:10 UTC (rev 7018)
@@ -10594,7 +10594,7 @@
"Suchergebnissen, etc. angezeigt wird. Sie sollte nicht so umfassend und "
"formal sein wie die Projektzweck-Beschreibung (Schritt 2), deshalb benutzen "
"Sie gerne knappe, präzise und einprägsame Formulierungen. Die maximale Länge "
-"beträgt 255 Zeichen."
+"beträgt 255 Zeichen.</p>"
#: www/register/projectinfo.php:147
#, fuzzy, php-format
More information about the evolvis-commits
mailing list