diff options
-rw-r--r-- | src/wp-includes/class-wp-query.php | 2 | ||||
-rw-r--r-- | src/wp-includes/rewrite.php | 6 | ||||
-rw-r--r-- | src/wp-includes/taxonomy.php | 2 | ||||
-rw-r--r-- | tests/phpunit/tests/kses.php | 71 |
4 files changed, 65 insertions, 16 deletions
diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php index 21127dc755..52121e2308 100644 --- a/src/wp-includes/class-wp-query.php +++ b/src/wp-includes/class-wp-query.php @@ -5005,7 +5005,7 @@ class WP_Query { * * These arrays are sorted in the query generator for the purposes of the * WHERE clause but the arguments are not modified as they can be used for - * the orderby clase. + * the orderby clause. * * Their use in the orderby clause will generate a different SQL query so * they can be sorted for the cache key generation. diff --git a/src/wp-includes/rewrite.php b/src/wp-includes/rewrite.php index 235c0c82e2..246846dc35 100644 --- a/src/wp-includes/rewrite.php +++ b/src/wp-includes/rewrite.php @@ -412,7 +412,7 @@ function wp_resolve_numeric_slug_conflicts( $query_vars = array() ) { // This is the potentially clashing slug. $value = ''; - if ( $compare && array_key_exists( $compare, $query_vars ) ) { + if ( array_key_exists( $compare, $query_vars ) ) { $value = $query_vars[ $compare ]; } @@ -460,9 +460,7 @@ function wp_resolve_numeric_slug_conflicts( $query_vars = array() ) { } // If we've gotten to this point, we have a slug/date clash. First, adjust for nextpage. - if ( '' !== $maybe_page ) { - $query_vars['page'] = (int) $maybe_page; - } + $query_vars['page'] = $maybe_page; // Next, unset autodetected date-related query vars. unset( $query_vars['year'] ); diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index 935212652c..70b407fda8 100644 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -1337,7 +1337,7 @@ function get_terms( $args = array(), $deprecated = '' ) { $args['taxonomy'] = $taxonomies; } else { $args = wp_parse_args( $args, $defaults ); - if ( isset( $args['taxonomy'] ) && null !== $args['taxonomy'] ) { + if ( isset( $args['taxonomy'] ) ) { $args['taxonomy'] = (array) $args['taxonomy']; } } diff --git a/tests/phpunit/tests/kses.php b/tests/phpunit/tests/kses.php index 256a3866ec..61baf0d0a1 100644 --- a/tests/phpunit/tests/kses.php +++ b/tests/phpunit/tests/kses.php @@ -551,18 +551,69 @@ EOF; } /** + * Data provider. + */ + public static function data_normalize_entities(): array { + return array( + /** + * These examples are from the wp_kses_normalize_entities function description. + */ + 'AT&T' => array( 'AT&T', 'AT&T' ), + ':' => array( ':', ':' ), + '&#XYZZY;' => array( '&#XYZZY;', '&#XYZZY;' ), + + 'Named ref &' => array( '♠', '♠' ), + 'Named ref &' => array( '♠', '♠' ), + 'Named ref ♠' => array( '♠', '♠' ), + 'Named ref ¹' => array( '¹', '¹' ), + 'Named ref ²' => array( '²', '²' ), + 'Named ref ³' => array( '³', '³' ), + 'Named ref ¼' => array( '¼', '¼' ), + 'Named ref ½' => array( '½', '½' ), + 'Named ref ¾' => array( '¾', '¾' ), + 'Named ref ∴' => array( '∴', '∴' ), + + 'Decimal ref 	 ( )' => array( '	', '	' ), + 'Decimal ref " (")' => array( '"', '"' ), + 'Decimal ref " (")' => array( '"', '"' ), + 'Decimal ref & (&)' => array( '&', '&' ), + "Decimal ref ' (')" => array( ''', ''' ), + 'Decimal ref 😍 (😍)' => array( '😍', '😍' ), + 'Decimal ref 😍 (😍)' => array( '😍', '😍' ), + + 'Hex ref 	 ( )' => array( '	', '	' ), + 'Hex ref " (")' => array( '"', '"' ), + 'Hex ref " (")' => array( '"', '"' ), + 'Hex ref & (&)' => array( '&', '&' ), + "Hex ref ' (')" => array( ''', ''' ), + 'Hex ref 😍 (😍)' => array( '😍', '😍' ), + 'Hex ref 😍 (😍)' => array( '😍', '😍' ), + + 'HEX REF " (")' => array( '"', '"' ), + 'HEX REF & (&)' => array( '&', '&' ), + "HEX REF ' (')" => array( ''', ''' ), + 'HEX REF 😍 (😍)' => array( '😍', '😍' ), + + 'Encoded named ref &' => array( '&', '&' ), + 'Encoded named ref &' => array( '&', '&' ), + 'Encoded named ref &' => array( '&', '&' ), + + /* + * The codepoint value here is outside of the valid unicode range whose + * maximum is 0x10FFFF or 1114111. + */ + 'Invalid decimal unicode �' => array( '�', '�' ), + 'Invalid hex unicode �' => array( '�', '�' ), + ); + } + + /** * @ticket 26290 + * + * @dataProvider data_normalize_entities */ - public function test_wp_kses_normalize_entities() { - $this->assertSame( '♠', wp_kses_normalize_entities( '♠' ) ); - - $this->assertSame( '¹', wp_kses_normalize_entities( '¹' ) ); - $this->assertSame( '²', wp_kses_normalize_entities( '²' ) ); - $this->assertSame( '³', wp_kses_normalize_entities( '³' ) ); - $this->assertSame( '¼', wp_kses_normalize_entities( '¼' ) ); - $this->assertSame( '½', wp_kses_normalize_entities( '½' ) ); - $this->assertSame( '¾', wp_kses_normalize_entities( '¾' ) ); - $this->assertSame( '∴', wp_kses_normalize_entities( '∴' ) ); + public function test_wp_kses_normalize_entities( string $input, string $expected ) { + $this->assertSame( $expected, wp_kses_normalize_entities( $input ) ); } /** |