From 814a876b43f4eddea39772e1290c5a782ed3909e Mon Sep 17 00:00:00 2001 From: ryan Date: Sat, 24 Jun 2006 01:20:01 +0000 Subject: [PATCH] js_escape() in onclicks. fixes #2851 git-svn-id: http://svn.automattic.com/wordpress/branches/2.0@3906 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-functions.php | 4 ++-- wp-admin/edit-form-advanced.php | 2 +- wp-admin/edit-page-form.php | 2 +- wp-admin/edit-pages.php | 2 +- wp-admin/link-categories.php | 2 +- wp-admin/link-manager.php | 2 +- wp-includes/functions-formatting.php | 3 ++- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index a0ecbb8250..441df1e96b 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -599,7 +599,7 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) { $default_cat_id = get_option('default_category'); if ($category->cat_ID != $default_cat_id) - $edit .= "cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . sprintf(__("You are about to delete the category "%s". All of its posts will go to the default category.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars($category->cat_name, 1))."' );\" class='delete'>".__('Delete').""; + $edit .= "cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . sprintf(__("You are about to delete the category "%s". All of its posts will go to the default category.\\n"OK" to delete, "Cancel" to stop."), js_escape($category->cat_name))."' );\" class='delete'>".__('Delete').""; else $edit .= "".__("Default"); } @@ -643,7 +643,7 @@ function page_rows($parent = 0, $level = 0, $pages = 0) { post_modified); ?> " . __('Edit') . ""; } ?> - " . __('Delete') . ""; } ?> + " . __('Delete') . ""; } ?> -post_title) ) . "') ) { document.forms.post._wpnonce.value = '$delete_nonce'; return true;}return false;\""; ?> /> +post_title) ) . "') ) { document.forms.post._wpnonce.value = '$delete_nonce'; return true;}return false;\""; ?> /> diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php index 0ffe19d9bd..65d0d0d935 100644 --- a/wp-admin/edit-page-form.php +++ b/wp-admin/edit-page-form.php @@ -220,7 +220,7 @@ if($metadata = has_meta($post_ID)) { - escape($post->post_title) ) . "')\""; ?> /> + post_title) ) . "')\""; ?> /> diff --git a/wp-admin/edit-pages.php b/wp-admin/edit-pages.php index f6d3f6c960..9dc89d7827 100644 --- a/wp-admin/edit-pages.php +++ b/wp-admin/edit-pages.php @@ -52,7 +52,7 @@ foreach ( $posts as $post ) : post_modified); ?> ID' class='edit'>" . __('Edit') . ""; } ?> - ID", 'delete-post_' . $post->ID) . "' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the "%s" page.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . ""; } ?> + ID", 'delete-post_' . $post->ID) . "' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the "%s" page.\\n"OK" to delete, "Cancel" to stop."), js_escape(get_the_title('','',0))) . "' );\">" . __('Delete') . ""; } ?> text_after_all)?> list_limit ?> - cat_id?>&action=Delete", 'delete-link-category_' . $row->cat_id) ?>" "onclick="return deleteSomething( 'link category', cat_id . ", '" . sprintf(__("You are about to delete the "%s" link category.\\n"Cancel" to stop, "OK" to delete."), wp_specialchars($row->cat_name,1)); ?>' );" class="delete"> + cat_id?>&action=Delete", 'delete-link-category_' . $row->cat_id) ?>" "onclick="return deleteSomething( 'link category', cat_id . ", '" . sprintf(__("You are about to delete the "%s" link category.\\n"Cancel" to stop, "OK" to delete."), js_escape($row->cat_name)); ?>' );" class="delete"> ' . __('Edit') . ''; - echo 'link_id , '".sprintf(__("You are about to delete the "%s" bookmark to %s.\\n"Cancel" to stop, "OK" to delete."), wp_specialchars($link->link_name, 1), wp_specialchars($link->link_url)).'\' );" class="delete">'.__('Delete').''; + echo 'link_id , '".sprintf(__("You are about to delete the "%s" bookmark to %s.\\n"Cancel" to stop, "OK" to delete."), js_escape($link->link_name), js_escape($link->link_url)).'\' );" class="delete">'.__('Delete').''; echo ''; } else { echo "   \n"; diff --git a/wp-includes/functions-formatting.php b/wp-includes/functions-formatting.php index 6bf32ddf2a..158567edb6 100644 --- a/wp-includes/functions-formatting.php +++ b/wp-includes/functions-formatting.php @@ -1019,6 +1019,7 @@ function wp_richedit_pre($text) { // Escape single quotes, specialchar double quotes, and fix line endings. function js_escape($text) { $text = wp_specialchars($text, 'double'); - return preg_replace("/\r?\n/", "\\n", addslashes($text)); + $text = str_replace(''', "'", $text); + return preg_replace("/\r?\n/", "\\n", addslashes($text)); } ?>