Explorar o código

special chars should be undone only after encoding

tokul %!s(int64=20) %!d(string=hai) anos
pai
achega
7220e57bed
Modificáronse 1 ficheiros con 10 adicións e 5 borrados
  1. 10 5
      functions/i18n.php

+ 10 - 5
functions/i18n.php

@@ -157,11 +157,6 @@ function charset_decode ($charset, $string) {
 function charset_encode($string,$charset,$htmlencode=true) {
     global $default_charset;
 
-    // Undo html special chars
-    if (! $htmlencode ) {
-        $string = str_replace(array('&amp;','&gt;','&lt;','&quot;'),array('&','>','<','"'),$string);
-    }
-
     $encode=fixcharset($charset);
     $encodefile=SM_PATH . 'functions/encode/' . $encode . '.php';
     if (file_exists($encodefile)) {
@@ -171,6 +166,16 @@ function charset_encode($string,$charset,$htmlencode=true) {
         include_once(SM_PATH . 'functions/encode/us_ascii.php');
         $ret = charset_encode_us_ascii($string);
     }
+
+    /**
+     * Undo html special chars, some places (like compose form) have
+     * own sanitizing functions and don't need html symbols.
+     * Undo chars only after encoding in order to prevent conversion of
+     * html entities in plain text emails.
+     */
+    if (! $htmlencode ) {
+        $ret = str_replace(array('&amp;','&gt;','&lt;','&quot;'),array('&','>','<','"'),$ret);
+    }
     return( $ret );
 }