js_escape improvements from Alexander Concha. Catches &#39 &#039 ' ' ' ' &#x000027 etc.

git-svn-id: http://svn.automattic.com/wordpress/branches/2.2@5735 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-06-19 22:47:01 +00:00
parent 4c6fc7b9b5
commit 296ccd1317
1 changed files with 1 additions and 1 deletions

View File

@ -1103,7 +1103,7 @@ function htmlentities2($myHTML) {
// Escape single quotes, specialchar double quotes, and fix line endings.
function js_escape($text) {
$safe_text = wp_specialchars($text, 'double');
$safe_text = str_replace(''', "'", $safe_text);
$safe_text = preg_replace('/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes($safe_text));
$safe_text = preg_replace("/\r?\n/", "\\n", addslashes($safe_text));
return apply_filters('js_escape', $safe_text, $text);
}