function charset_encode($string,$charset,$htmlencode=true) {
global $default_charset;
- // Undo html special chars
- if (! $htmlencode ) {
- $string = str_replace(array('&','>','<','"'),array('&','>','<','"'),$string);
- }
-
$encode=fixcharset($charset);
$encodefile=SM_PATH . 'functions/encode/' . $encode . '.php';
if (file_exists($encodefile)) {
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('&','>','<','"'),array('&','>','<','"'),$ret);
+ }
return( $ret );
}