mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Don't double-escape terms payload in WP_Tax_Query::transform_query().
`terms` values are passed through `sanitize_term_field()` with the 'db' flag, which add slashes. Because `terms` are subsequently run through `esc_sql()`, these slashes must be removed. See [36348], which added a similar step to sanitization in `get_terms()`. Props bcworkz. Fixes #39315. git-svn-id: https://develop.svn.wordpress.org/trunk@39662 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1380,4 +1380,33 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
|
||||
_unregister_taxonomy( 'foo' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 39315
|
||||
*/
|
||||
public function test_tax_terms_should_not_be_double_escaped() {
|
||||
$name = "Don't worry be happy";
|
||||
|
||||
register_taxonomy( 'wptests_tax', 'post' );
|
||||
$t = self::factory()->term->create( array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
'name' => $name,
|
||||
) );
|
||||
|
||||
$p = self::factory()->post->create();
|
||||
wp_set_object_terms( $p, array( $t ), 'wptests_tax' );
|
||||
|
||||
$q = new WP_Query( array(
|
||||
'fields' => 'ids',
|
||||
'tax_query' => array(
|
||||
array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
'field' => 'name',
|
||||
'terms' => $name,
|
||||
),
|
||||
),
|
||||
) );
|
||||
|
||||
$this->assertEqualSets( array( $p ), $q->posts );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user