Skip to content

Commit 5abece7

Browse files
committed
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develop into iapi-load-on-client-navigation
2 parents 743c905 + b5e4bd8 commit 5abece7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1244
-165
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ wp-tests-config.php
5050
/src/wp-content/fonts
5151
/src/wp-content/languages
5252
/src/wp-content/mu-plugins
53-
/src/wp-content/plugins/*
54-
!/src/wp-content/plugins/hello-dolly
53+
/src/wp-content/plugins
5554
/src/wp-content/themes/*
5655
!/src/wp-content/themes/twentyten
5756
!/src/wp-content/themes/twentyeleven

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = function(grunt) {
2828
'wp-content/themes/index.php',
2929
'wp-content/themes/twenty*/**',
3030
'wp-content/plugins/index.php',
31-
'wp-content/plugins/hello-dolly/**',
31+
'wp-content/plugins/hello.php',
3232
'wp-content/plugins/akismet/**',
3333
'!wp-content/themes/twenty*/node_modules/**',
3434
],

src/wp-admin/includes/plugin.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup
153153
load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) );
154154
}
155155
}
156+
} elseif ( 'hello.php' === basename( $plugin_file ) ) {
157+
$textdomain = 'default';
156158
}
157159
if ( $textdomain ) {
158160
foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) {
@@ -1006,6 +1008,10 @@ function delete_plugins( $plugins, $deprecated = '' ) {
10061008

10071009
$plugin_slug = dirname( $plugin_file );
10081010

1011+
if ( 'hello.php' === $plugin_file ) {
1012+
$plugin_slug = 'hello-dolly';
1013+
}
1014+
10091015
// Remove language files, silently.
10101016
if ( '.' !== $plugin_slug && ! empty( $plugin_translations[ $plugin_slug ] ) ) {
10111017
$translations = $plugin_translations[ $plugin_slug ];

src/wp-admin/includes/update-core.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -841,8 +841,6 @@
841841
'wp-includes/js/dist/undo-manager.min.js',
842842
'wp-includes/js/dist/fields.min.js',
843843
'wp-includes/js/dist/fields.js',
844-
// 6.9
845-
'wp-content/plugins/hello.php',
846844
);
847845

848846
/**
@@ -975,7 +973,6 @@
975973
'themes/twentytwentythree/' => '6.1',
976974
'themes/twentytwentyfour/' => '6.4',
977975
'themes/twentytwentyfive/' => '6.7',
978-
'plugins/hello-dolly/' => '6.9',
979976
);
980977

981978
/**

src/wp-admin/includes/upgrade.php

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -886,10 +886,6 @@ function upgrade_all() {
886886
upgrade_682();
887887
}
888888

889-
if ( $wp_current_db_version < 60717 ) {
890-
upgrade_690();
891-
}
892-
893889
maybe_disable_link_manager();
894890

895891
maybe_disable_automattic_widgets();
@@ -2485,31 +2481,6 @@ function ( $url ) {
24852481
}
24862482
}
24872483

2488-
/**
2489-
* Executes changes made in WordPress 6.9.0.
2490-
*
2491-
* @ignore
2492-
* @since 6.9.0
2493-
*
2494-
* @global int $wp_current_db_version The old (current) database version.
2495-
*/
2496-
function upgrade_690() {
2497-
global $wp_current_db_version;
2498-
2499-
if ( $wp_current_db_version < 60717 ) {
2500-
// Switch Hello Dolly from file to directory format. See #53323
2501-
$active_plugins = (array) get_option( 'active_plugins', array() );
2502-
$old_plugin = 'hello.php';
2503-
$new_plugin = 'hello-dolly/hello.php';
2504-
$key = array_search( $old_plugin, $active_plugins, true );
2505-
2506-
if ( $key ) {
2507-
$active_plugins[ $key ] = $new_plugin;
2508-
update_option( 'active_plugins', $active_plugins );
2509-
}
2510-
}
2511-
}
2512-
25132484
/**
25142485
* Executes network-level upgrade routines.
25152486
*
File renamed without changes.

src/wp-includes/class-wp-plugin-dependencies.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,9 @@ protected static function check_for_circular_dependencies( $dependents, $depende
870870
* @return string The plugin's slug.
871871
*/
872872
protected static function convert_to_slug( $plugin_file ) {
873+
if ( 'hello.php' === $plugin_file ) {
874+
return 'hello-dolly';
875+
}
873876
return str_contains( $plugin_file, '/' ) ? dirname( $plugin_file ) : str_replace( '.php', '', $plugin_file );
874877
}
875878
}

src/wp-includes/compat-utf8.php

Lines changed: 59 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,29 @@
2828
* 1 === _wp_scan_utf8( $pineapple, $at, $invalid_length );
2929
* $at === 4; $invalid_length === 0;
3030
*
31-
* Note! This functions many arguments are passed without and “options”
32-
* array. This choice is based on the fact that this is a low-level function
33-
* and there’s no need to create an array of items on every invocation.
31+
* Note! While passing an options array here might be convenient from a calling-code standpoint,
32+
* this function is intended to serve as a very low-level foundation upon which to build
33+
* higher level functionality. For the sake of keeping costs explicit all arguments are
34+
* passed directly.
3435
*
3536
* @since 6.9.0
3637
* @access private
3738
*
38-
* @param string $bytes UTF-8 encoded string which might include invalid spans of bytes.
39-
* @param int $at Where to start scanning.
40-
* @param int $invalid_length Will be set to how many bytes are to be ignored after `$at`.
41-
* @param int|null $max_bytes Stop scanning after this many bytes have been seen.
42-
* @param int|null $max_code_points Stop scanning after this many code points have been seen.
39+
* @param string $bytes UTF-8 encoded string which might include invalid spans of bytes.
40+
* @param int $at Where to start scanning.
41+
* @param int $invalid_length Will be set to how many bytes are to be ignored after `$at`.
42+
* @param int|null $max_bytes Stop scanning after this many bytes have been seen.
43+
* @param int|null $max_code_points Stop scanning after this many code points have been seen.
44+
* @param bool|null $has_noncharacters Set to indicate if scanned string contained noncharacters.
4345
* @return int How many code points were successfully scanned.
4446
*/
45-
function _wp_scan_utf8( string $bytes, int &$at, int &$invalid_length, ?int $max_bytes = null, ?int $max_code_points = null ): int {
46-
$byte_length = strlen( $bytes );
47-
$end = min( $byte_length, $at + ( $max_bytes ?? PHP_INT_MAX ) );
48-
$invalid_length = 0;
49-
$count = 0;
50-
$max_count = $max_code_points ?? PHP_INT_MAX;
47+
function _wp_scan_utf8( string $bytes, int &$at, int &$invalid_length, ?int $max_bytes = null, ?int $max_code_points = null, ?bool &$has_noncharacters = null ): int {
48+
$byte_length = strlen( $bytes );
49+
$end = min( $byte_length, $at + ( $max_bytes ?? PHP_INT_MAX ) );
50+
$invalid_length = 0;
51+
$count = 0;
52+
$max_count = $max_code_points ?? PHP_INT_MAX;
53+
$has_noncharacters = false;
5154

5255
for ( $i = $at; $i < $end && $count <= $max_count; $i++ ) {
5356
/*
@@ -145,6 +148,15 @@ function _wp_scan_utf8( string $bytes, int &$at, int &$invalid_length, ?int $max
145148
) {
146149
++$count;
147150
$i += 2;
151+
152+
// Covers the range U+FDD0–U+FDEF, U+FFFE, U+FFFF.
153+
if ( 0xEF === $b1 ) {
154+
$has_noncharacters |= (
155+
( 0xB7 === $b2 && $b3 >= 0x90 && $b3 <= 0xAF ) ||
156+
( 0xBF === $b2 && ( 0xBE === $b3 || 0xBF === $b3 ) )
157+
);
158+
}
159+
148160
continue;
149161
}
150162

@@ -162,6 +174,14 @@ function _wp_scan_utf8( string $bytes, int &$at, int &$invalid_length, ?int $max
162174
) {
163175
++$count;
164176
$i += 3;
177+
178+
// Covers U+1FFFE, U+1FFFF, U+2FFFE, U+2FFFF, …, U+10FFFE, U+10FFFF.
179+
$has_noncharacters |= (
180+
( 0x0F === ( $b2 & 0x0F ) ) &&
181+
0xBF === $b3 &&
182+
( 0xBE === $b4 || 0xBF === $b4 )
183+
);
184+
165185
continue;
166186
}
167187

@@ -380,6 +400,31 @@ function _wp_utf8_codepoint_span( string $text, int $byte_offset, int $max_code_
380400
return $byte_offset - $was_at;
381401
}
382402

403+
/**
404+
* Fallback support for determining if a string contains Unicode noncharacters.
405+
*
406+
* @since 6.9.0
407+
* @access private
408+
*
409+
* @see \wp_has_noncharacters()
410+
*
411+
* @param string $text Are there noncharacters in this string?
412+
* @return bool Whether noncharacters were found in the string.
413+
*/
414+
function _wp_has_noncharacters_fallback( string $text ): bool {
415+
$at = 0;
416+
$invalid_length = 0;
417+
$has_noncharacters = false;
418+
$end = strlen( $text );
419+
420+
while ( $at < $end && ! $has_noncharacters ) {
421+
_wp_scan_utf8( $text, $at, $invalid_length, null, null, $has_noncharacters );
422+
$at += $invalid_length;
423+
}
424+
425+
return $has_noncharacters;
426+
}
427+
383428
/**
384429
* Converts a string from ISO-8859-1 to UTF-8, maintaining backwards compatibility
385430
* with the deprecated function from the PHP standard library.

src/wp-includes/default-filters.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@
595595
add_action( 'enqueue_block_assets', 'wp_enqueue_classic_theme_styles' );
596596
add_action( 'enqueue_block_assets', 'wp_enqueue_registered_block_scripts_and_styles' );
597597
add_action( 'enqueue_block_assets', 'enqueue_block_styles_assets', 30 );
598+
add_action( 'init', 'wp_load_classic_theme_block_styles_on_demand', 8 ); // Must happen before register_core_block_style_handles() at priority 9.
598599
/*
599600
* `wp_enqueue_registered_block_scripts_and_styles` is bound to both
600601
* `enqueue_block_editor_assets` and `enqueue_block_assets` hooks

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

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3930,41 +3930,32 @@ public function set_attribute( $name, $value ): bool {
39303930
return false;
39313931
}
39323932

3933-
/*
3933+
$name_length = strlen( $name );
3934+
3935+
/**
39343936
* WordPress rejects more characters than are strictly forbidden
39353937
* in HTML5. This is to prevent additional security risks deeper
3936-
* in the WordPress and plugin stack. Specifically the
3937-
* less-than (<) greater-than (>) and ampersand (&) aren't allowed.
3938+
* in the WordPress and plugin stack. Specifically the following
3939+
* are not allowed to be set as part of an HTML attribute name:
39383940
*
3939-
* The use of a PCRE match enables looking for specific Unicode
3940-
* code points without writing a UTF-8 decoder. Whereas scanning
3941-
* for one-byte characters is trivial (with `strcspn`), scanning
3942-
* for the longer byte sequences would be more complicated. Given
3943-
* that this shouldn't be in the hot path for execution, it's a
3944-
* reasonable compromise in efficiency without introducing a
3945-
* noticeable impact on the overall system.
3941+
* - greater-than “>”
3942+
* - ampersand “&”
39463943
*
39473944
* @see https://html.spec.whatwg.org/#attributes-2
3948-
*
3949-
* @todo As the only regex pattern maybe we should take it out?
3950-
* Are Unicode patterns available broadly in Core?
39513945
*/
3952-
if ( preg_match(
3953-
'~[' .
3954-
// Syntax-like characters.
3955-
'"\'>&</ =' .
3956-
// Control characters.
3957-
'\x{00}-\x{1F}' .
3958-
// HTML noncharacters.
3959-
'\x{FDD0}-\x{FDEF}' .
3960-
'\x{FFFE}\x{FFFF}\x{1FFFE}\x{1FFFF}\x{2FFFE}\x{2FFFF}\x{3FFFE}\x{3FFFF}' .
3961-
'\x{4FFFE}\x{4FFFF}\x{5FFFE}\x{5FFFF}\x{6FFFE}\x{6FFFF}\x{7FFFE}\x{7FFFF}' .
3962-
'\x{8FFFE}\x{8FFFF}\x{9FFFE}\x{9FFFF}\x{AFFFE}\x{AFFFF}\x{BFFFE}\x{BFFFF}' .
3963-
'\x{CFFFE}\x{CFFFF}\x{DFFFE}\x{DFFFF}\x{EFFFE}\x{EFFFF}\x{FFFFE}\x{FFFFF}' .
3964-
'\x{10FFFE}\x{10FFFF}' .
3965-
']~Ssu',
3966-
$name
3967-
) ) {
3946+
if (
3947+
0 === $name_length ||
3948+
// Syntax-like characters.
3949+
strcspn( $name, '"\'>&</ =' ) !== $name_length ||
3950+
// Control characters.
3951+
strcspn(
3952+
$name,
3953+
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F" .
3954+
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"
3955+
) !== $name_length ||
3956+
// Unicode noncharacters.
3957+
wp_has_noncharacters( $name )
3958+
) {
39683959
_doing_it_wrong(
39693960
__METHOD__,
39703961
__( 'Invalid attribute name.' ),

0 commit comments

Comments
 (0)