From 545cc85918c8dcbf9444c4d59a081364d42fc7a7 Mon Sep 17 00:00:00 2001 From: Ryan Boren 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: https://develop.svn.wordpress.org/trunk@17256 602fd350-edb4-49c9-b593-d223f7449a82 --- 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;