From 8dbe915535e313d2cfc651b1eb2bc7a157652970 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 11 Jan 2011 20:15:25 +0000 Subject: [PATCH] Strip and prepare ajax tag search string. Avoids applying slashes toward the character count. Props brianlayman. see #13580 git-svn-id: http://svn.automattic.com/wordpress/trunk@17256 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-ajax.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index ef46ccdc66..cd48d4398a 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -86,7 +86,7 @@ case 'ajax-tag-search' : die('0'); } - $s = $_GET['q']; // is this slashed already? + $s = stripslashes( $_GET['q'] ); if ( false !== strpos( $s, ',' ) ) { $s = explode( ',', $s ); @@ -96,7 +96,7 @@ case 'ajax-tag-search' : if ( strlen( $s ) < 2 ) die; // require 2 chars for matching - $results = $wpdb->get_col( "SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = '$taxonomy' AND t.name LIKE ('%" . $s . "%')" ); + $results = $wpdb->get_col( $wpdb->prepare( "SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.name LIKE (%s)", $taxonomy, '%' . like_escape( $s ) . '%' ) ); echo join( $results, "\n" ); die;