? mail-decode-html4-entities-v2.patch
? sites/default/files
? sites/default/settings.php
Index: includes/mail.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/mail.inc,v
retrieving revision 1.7
diff -u -p -r1.7 mail.inc
--- includes/mail.inc 4 Sep 2007 21:10:45 -0000 1.7
+++ includes/mail.inc 24 Jan 2008 10:31:09 -0000
@@ -388,7 +388,9 @@ function drupal_html_to_text($string, $a
// Process blocks of text.
else {
// Convert inline HTML text to plain text.
- $value = trim(preg_replace('/\s+/', ' ', decode_entities($value)));
+ $value = trim(preg_replace('/\s+/', ' ', html_entity_decode(
+ preg_replace_callback('/&([a-zA-Z][a-zA-Z0-9]+);/', '_drupal_decode_entities',
+ $value), ENT_COMPAT, 'ISO-8859-1')));
if (strlen($value)) {
$chunk = $value;
}
@@ -413,6 +415,72 @@ function drupal_html_to_text($string, $a
}
/**
+ * Helper function for drupal_html_to_text().
+ *
+ * Full HTML 4 entity lookup.
+ */
+function _drupal_decode_entities($matches) {
+ static $table = array('OElig' => 'Œ','oelig' => 'œ','Scaron' => 'Š',
+ 'scaron' => 'š','Yuml' => 'Ÿ','circ' => 'ˆ',
+ 'tilde' => '˜','ensp' => ' ','emsp' => ' ',
+ 'thinsp' => ' ','zwnj' => '','zwj' => '',
+ 'lrm' => '','rlm' => '','ndash' => '–',
+ 'mdash' => '—','lsquo' => '‘','rsquo' => '’',
+ 'sbquo' => '‚','ldquo' => '“','rdquo' => '”',
+ 'bdquo' => '„','dagger' => '†','Dagger' => '‡',
+ 'permil' => '‰','lsaquo' => '‹','rsaquo' => '›',
+ 'euro' => '€','fnof' => 'ƒ','Alpha' => 'Α',
+ 'Beta' => 'Β','Gamma' => 'Γ','Delta' => 'Δ',
+ 'Epsilon' => 'Ε','Zeta' => 'Ζ','Eta' => 'Η',
+ 'Theta' => 'Θ','Iota' => 'Ι','Kappa' => 'Κ',
+ 'Lambda' => 'Λ','Mu' => 'Μ','Nu' => 'Ν',
+ 'Xi' => 'Ξ','Omicron' => 'Ο','Pi' => 'Π',
+ 'Rho' => 'Ρ','Sigma' => 'Σ','Tau' => 'Τ',
+ 'Upsilon' => 'Υ','Phi' => 'Φ','Chi' => 'Χ',
+ 'Psi' => 'Ψ','Omega' => 'Ω','alpha' => 'α',
+ 'beta' => 'β','gamma' => 'γ','delta' => 'δ',
+ 'epsilon' => 'ε','zeta' => 'ζ','eta' => 'η',
+ 'theta' => 'θ','iota' => 'ι','kappa' => 'κ',
+ 'lambda' => 'λ','mu' => 'μ','nu' => 'ν',
+ 'xi' => 'ξ','omicron' => 'ο','pi' => 'π',
+ 'rho' => 'ρ','sigmaf' => 'ς','sigma' => 'σ',
+ 'tau' => 'τ','upsilon' => 'υ','phi' => 'φ',
+ 'chi' => 'χ','psi' => 'ψ','omega' => 'ω',
+ 'thetasym' => 'ϑ','upsih' => 'ϒ','piv' => 'ϖ',
+ 'bull' => '•','hellip' => '…','prime' => '′',
+ 'Prime' => '″','oline' => '‾','frasl' => '⁄',
+ 'weierp' => '℘','image' => 'ℑ','real' => 'ℜ',
+ 'trade' => '™','alefsym' => 'ℵ','larr' => '←',
+ 'uarr' => '↑','rarr' => '→','darr' => '↓',
+ 'harr' => '↔','crarr' => '↵','lArr' => '⇐',
+ 'uArr' => '⇑','rArr' => '⇒','dArr' => '⇓',
+ 'hArr' => '⇔','forall' => '∀','part' => '∂',
+ 'exist' => '∃','empty' => '∅','nabla' => '∇',
+ 'isin' => '∈','notin' => '∉','ni' => '∋',
+ 'prod' => '∏','sum' => '∑','minus' => '−',
+ 'lowast' => '∗','radic' => '√','prop' => '∝',
+ 'infin' => '∞','ang' => '∠','and' => '∧',
+ 'or' => '∨','cap' => '∩','cup' => '∪',
+ 'int' => '∫','there4' => '∴','sim' => '∼',
+ 'cong' => '≅','asymp' => '≈','ne' => '≠',
+ 'equiv' => '≡','le' => '≤','ge' => '≥',
+ 'sub' => '⊂','sup' => '⊃','nsub' => '⊄',
+ 'sube' => '⊆','supe' => '⊇','oplus' => '⊕',
+ 'otimes' => '⊗','perp' => '⊥','sdot' => '⋅',
+ 'lceil' => '⌈','rceil' => '⌉','lfloor' => '⌊',
+ 'rfloor' => '⌋','lang' => '〈','rang' => '〉',
+ 'loz' => '◊','spades' => '♠','clubs' => '♣',
+ 'hearts' => '♥','diams' => '♦');
+
+ if(isset($table[$matches[1]])) {
+ return $table[$matches[1]];
+ }
+ else {
+ return html_entity_decode('&' . $matches[1]);
+ }
+}
+
+/**
* Helper function for array_walk in drupal_wrap_mail().
*
* Wraps words on a single line.