Skip to content

Commit 303cc00

Browse files
committed
Merge remote-tracking branch 'upstream/trunk' into bugfix/30575-submenu-touch-support
2 parents 3d403cc + a0fa6f2 commit 303cc00

File tree

6 files changed

+186
-8
lines changed

6 files changed

+186
-8
lines changed

src/wp-admin/includes/class-wp-terms-list-table.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ class WP_Terms_List_Table extends WP_List_Table {
2727
*
2828
* @see WP_List_Table::__construct() for more information on default arguments.
2929
*
30-
* @global string $post_type Global post type.
31-
* @global string $taxonomy Global taxonomy.
32-
* @global string $action
33-
* @global object $tax
30+
* @global string $post_type Global post type.
31+
* @global string $taxonomy Global taxonomy.
32+
* @global string $action
33+
* @global WP_Taxonomy $tax Global taxonomy object.
3434
*
3535
* @param array $args An associative array of arguments.
3636
*/

src/wp-includes/html-api/class-wp-html-doctype-info.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
*
5151
* @since 6.7.0
5252
*
53+
* @access private
54+
*
5355
* @see WP_HTML_Processor
5456
*/
5557
class WP_HTML_Doctype_Info {

src/wp-includes/html-api/class-wp-html-processor.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,14 +1760,19 @@ private function step_in_head(): bool {
17601760
case '+META':
17611761
$this->insert_html_element( $this->state->current_token );
17621762

1763+
// All following conditions depend on "tentative" encoding confidence.
1764+
if ( 'tentative' !== $this->state->encoding_confidence ) {
1765+
return true;
1766+
}
1767+
17631768
/*
17641769
* > If the active speculative HTML parser is null, then:
17651770
* > - If the element has a charset attribute, and getting an encoding from
17661771
* > its value results in an encoding, and the confidence is currently
17671772
* > tentative, then change the encoding to the resulting encoding.
17681773
*/
17691774
$charset = $this->get_attribute( 'charset' );
1770-
if ( is_string( $charset ) && 'tentative' === $this->state->encoding_confidence ) {
1775+
if ( is_string( $charset ) ) {
17711776
$this->bail( 'Cannot yet process META tags with charset to determine encoding.' );
17721777
}
17731778

@@ -1784,8 +1789,7 @@ private function step_in_head(): bool {
17841789
if (
17851790
is_string( $http_equiv ) &&
17861791
is_string( $content ) &&
1787-
0 === strcasecmp( $http_equiv, 'Content-Type' ) &&
1788-
'tentative' === $this->state->encoding_confidence
1792+
0 === strcasecmp( $http_equiv, 'Content-Type' )
17891793
) {
17901794
$this->bail( 'Cannot yet process META tags with http-equiv Content-Type to determine encoding.' );
17911795
}

src/wp-includes/theme.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3771,7 +3771,7 @@ function _wp_customize_loader_settings() {
37713771
function wp_customize_url( $stylesheet = '' ) {
37723772
$url = admin_url( 'customize.php' );
37733773
if ( $stylesheet ) {
3774-
$url .= '?theme=' . urlencode( $stylesheet );
3774+
$url = add_query_arg( 'theme', urlencode( $stylesheet ), $url );
37753775
}
37763776
return esc_url( $url );
37773777
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* Unit tests covering WP_HTML_Processor META tag handling.
4+
*
5+
* @package WordPress
6+
* @subpackage HTML-API
7+
*
8+
* @since 6.9
9+
*
10+
* @group html-api
11+
*
12+
* @coversDefaultClass WP_HTML_Processor
13+
*/
14+
class Tests_HtmlApi_WpHtmlProcessorMetaTag extends WP_UnitTestCase {
15+
/**
16+
* Data provider.
17+
*/
18+
public static function data_supported_meta_tags(): array {
19+
return array(
20+
'No attributes' => array( '<meta>' ),
21+
'Unrelated attributes' => array( '<meta not-charset="OK">' ),
22+
'Boolean charset' => array( '<meta charset>' ),
23+
'HTTP Equiv: accept' => array( '<meta http-equiv="accept" content="">' ),
24+
'HTTP Equiv: content-type, no content' => array( '<meta http-equiv="content-type">' ),
25+
'Boolean HTTP Equiv' => array( '<meta http-equiv content="">' ),
26+
);
27+
}
28+
29+
/**
30+
* Ensures that META tags correctly handle encoding confidence.
31+
*
32+
* @ticket 63738
33+
*
34+
* @dataProvider data_supported_meta_tags
35+
*/
36+
public function test_supported_meta_tag( string $html ) {
37+
$html = '<!DOCTYPE html>' . $html;
38+
$processor = new class($html) extends WP_HTML_Processor {
39+
public function __construct( $html ) {
40+
parent::__construct( $html, parent::CONSTRUCTOR_UNLOCK_CODE );
41+
}
42+
};
43+
44+
$this->assertTrue( $processor->next_tag( 'META' ) );
45+
}
46+
47+
/**
48+
* Data provider.
49+
*/
50+
public static function data_unsupported_meta_tags(): array {
51+
return array(
52+
'With charset' => array( '<meta charset="utf8">', 'Cannot yet process META tags with charset to determine encoding.' ),
53+
'With CHARSET' => array( '<meta CHARSET="utf8">', 'Cannot yet process META tags with charset to determine encoding.' ),
54+
'With http-equiv' => array( '<meta http-equiv="content-type" content="">', 'Cannot yet process META tags with http-equiv Content-Type to determine encoding.' ),
55+
'With http-equiv and content' => array( '<meta http-equiv="Content-Type" content="UTF-8">', 'Cannot yet process META tags with http-equiv Content-Type to determine encoding.' ),
56+
);
57+
}
58+
59+
/**
60+
* Ensures that unsupported encoding META tags bail.
61+
*
62+
* @ticket 63738
63+
*
64+
* @dataProvider data_unsupported_meta_tags
65+
*/
66+
public function test_unsupported_meta_tags( string $html, string $unsupported_message ) {
67+
$html = '<!DOCTYPE html>' . $html;
68+
$processor = new class($html) extends WP_HTML_Processor {
69+
public function __construct( $html ) {
70+
parent::__construct( $html, parent::CONSTRUCTOR_UNLOCK_CODE );
71+
}
72+
};
73+
74+
$this->assertFalse( $processor->next_tag( 'META' ) );
75+
$this->assertInstanceOf( WP_HTML_Unsupported_Exception::class, $processor->get_unsupported_exception() );
76+
}
77+
}

tests/phpunit/tests/theme/wpTheme.php

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,101 @@ public function test_get_files_nonexistent_theme() {
375375
$this->assertEmpty( $files );
376376
}
377377

378+
/**
379+
* Test wp_customize_url with no $stylesheet argument.
380+
*
381+
* @ticket 63632
382+
*
383+
* @covers ::wp_customize_url
384+
*/
385+
public function test_wp_customize_url_no_stylesheet() {
386+
$this->assertSame( esc_url( admin_url( 'customize.php' ) ), wp_customize_url() );
387+
}
388+
389+
/**
390+
* Test wp_customize_url with no query args.
391+
*
392+
* @ticket 63632
393+
*
394+
* @covers ::wp_customize_url
395+
*/
396+
public function test_wp_customize_url_without_query_args() {
397+
$this->assertSame( esc_url( admin_url( 'customize.php?theme=foo' ) ), wp_customize_url( 'foo' ) );
398+
}
399+
400+
/**
401+
* Test wp_customize_url with existing query args.
402+
*
403+
* @ticket 63632
404+
*
405+
* @covers ::wp_customize_url
406+
*/
407+
public function test_wp_customize_url_with_existing_query_args() {
408+
$clean_admin_url = admin_url( 'customize.php' );
409+
410+
// Ensure the existing query arg is present in the URL.
411+
add_filter(
412+
'admin_url',
413+
static function ( $url ) {
414+
return add_query_arg( 'existing_arg', 'value', $url );
415+
}
416+
);
417+
$this->assertSame( esc_url( $clean_admin_url . '?existing_arg=value&theme=foo' ), wp_customize_url( 'foo' ) );
418+
}
419+
420+
/**
421+
* Test wp_customize_url with existing theme query arg.
422+
*
423+
* @ticket 63632
424+
*
425+
* @covers ::wp_customize_url
426+
*/
427+
public function test_wp_customize_url_with_existing_theme_query_arg() {
428+
$clean_admin_url = admin_url( 'customize.php' );
429+
430+
// Ensure the theme query arg is replaced with the new value.
431+
add_filter(
432+
'admin_url',
433+
static function ( $url ) {
434+
return add_query_arg( 'theme', 'to-be-replaced', $url );
435+
}
436+
);
437+
$this->assertSame( esc_url( $clean_admin_url . '?theme=foo' ), wp_customize_url( 'foo' ) );
438+
}
439+
440+
/**
441+
* Test wp_customize_url with multiple theme query args in array syntax.
442+
*
443+
* @ticket 63632
444+
*
445+
* @covers ::wp_customize_url
446+
*/
447+
public function test_wp_customize_url_with_multiple_theme_query_args() {
448+
$clean_admin_url = admin_url( 'customize.php' );
449+
450+
// Ensure the theme query arg is replaced with the new value.
451+
add_filter(
452+
'admin_url',
453+
static function ( $url ) {
454+
return add_query_arg( array( 'theme' => array( 'to-be-replaced-1', 'to-be-replaced-2' ) ), $url );
455+
}
456+
);
457+
$this->assertSame( esc_url( $clean_admin_url . '?theme=foo' ), wp_customize_url( 'foo' ) );
458+
}
459+
460+
/**
461+
* Test wp_customize_url with special characters in the theme name.
462+
*
463+
* @ticket 63632
464+
*
465+
* @covers ::wp_customize_url
466+
*/
467+
public function test_wp_customize_url_with_special_chars() {
468+
$stylesheet = 'foo!@-_ +';
469+
$expected = admin_url( 'customize.php?theme=' . urlencode( $stylesheet ) );
470+
$this->assertSame( esc_url( $expected ), wp_customize_url( $stylesheet ) );
471+
}
472+
378473
/**
379474
* Data provider.
380475
*

0 commit comments

Comments
 (0)