Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.756.2.84 diff -u -p -r1.756.2.84 common.inc --- includes/common.inc 19 May 2010 14:59:34 -0000 1.756.2.84 +++ includes/common.inc 20 May 2010 19:52:10 -0000 @@ -2443,9 +2443,22 @@ function drupal_to_js($var) { return $var; case 'resource': case 'string': - return '"'. str_replace(array("\r", "\n", "<", ">", "&"), - array('\r', '\n', '\x3c', '\x3e', '\x26'), - addslashes($var)) .'"'; + $replace_pairs = array( + "\\" => '\u005c', + "<" => '\u003c', + ">" => '\u003e', + "&" => '\u0026', + '"' => '\u0022', + '/' => '\u002f', + "\xc2\x85" => '\u0085', // Next Line + "\xe2\x80\xa8" => '\u2028', // Line Separator + "\xe2\x80\xa9" => '\u2029', // Paragraph Separator + ); + // Remaining unicode replacements. + for ($i = 0; $i < 32; $i++) { + $replace_pairs[html_entity_decode('&#'. $i .';', ENT_NOQUOTES, 'UTF-8')] = '\u00' . sprintf("%02s", dechex($i)); + } + return '"'. strtr($var, $replace_pairs) .'"'; case 'array': // Arrays in JSON can't be associative. If the array is empty or if it // has sequential whole number keys starting with 0, it's not associative