Skip to content

Commit c8ab01d

Browse files
committed
Security: Backport the WordPress 7.1.4 security fixes to the 6.4 branch.
- Users: Escape user login - Privacy: Harden column_email() output escaping in request list tables - Editor: Align block-delimiter whitespace matching between the PHP and JavaScript parsers. - Customizer: Improve changeset handling. - Upgrade/Install: Improve the handling of the upgrade working directory. - Customize: Resolve selective refresh partial placements as selectors only - Interactivity API: Harden directive processing and client-side navigation - Block parser: Only accept HTML whitespace in block delimiters - Use the HTML API to insert the Image lightbox button and the Playlist waveform player - Escape the labels of the post navigation and comments pagination links This also updates @wordpress/block-library@8.19.20, @wordpress/block-serialization-default-parser@4.42.14, @wordpress/interactivity@2.3.14. Merges [64873], [64874], [64876], [64877], [64879] to the 6.4 branch. Props xknown, jeremyfelt, jorbin, rfaile313, westonruter, jonsurrell, dmsnell, lancewillett, umut3806, marcs0h, luisherranz, ntsekouras, santosguillamot, darerodz, johnbillion, antonade. git-svn-id: https://develop.svn.wordpress.org/branches/6.4@64917 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 930f518 commit c8ab01d

30 files changed

Lines changed: 145 additions & 80 deletions

‎package-lock.json‎

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@
8888
"@wordpress/blob": "3.42.13",
8989
"@wordpress/block-directory": "4.19.18",
9090
"@wordpress/block-editor": "12.10.14",
91-
"@wordpress/block-library": "8.19.19",
92-
"@wordpress/block-serialization-default-parser": "4.42.13",
91+
"@wordpress/block-library": "8.19.20",
92+
"@wordpress/block-serialization-default-parser": "4.42.14",
9393
"@wordpress/blocks": "12.19.13",
9494
"@wordpress/commands": "0.13.14",
9595
"@wordpress/components": "25.8.14",
@@ -114,7 +114,7 @@
114114
"@wordpress/html-entities": "3.42.13",
115115
"@wordpress/i18n": "4.42.13",
116116
"@wordpress/icons": "9.33.13",
117-
"@wordpress/interactivity": "2.3.13",
117+
"@wordpress/interactivity": "2.3.14",
118118
"@wordpress/interface": "5.19.14",
119119
"@wordpress/is-shallow-equal": "4.42.13",
120120
"@wordpress/keyboard-shortcuts": "4.19.13",

‎src/js/_enqueues/wp/customize/preview-widgets.js‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,18 +415,25 @@ wp.customize.widgetsPreview = wp.customize.WidgetCustomizerPreview = (function(
415415
* @return {wp.customize.selectiveRefresh.Partial} The widget instance partial.
416416
*/
417417
ensureWidgetPlacementContainers: function( widgetId ) {
418-
var sidebarPartial = this, widgetPartial, wasInserted = false, partialId = 'widget[' + widgetId + ']';
418+
var sidebarPartial = this, sidebarArgs, widgetPartial, wasInserted = false, partialId = 'widget[' + widgetId + ']';
419419
widgetPartial = api.selectiveRefresh.partial( partialId );
420420
if ( ! widgetPartial ) {
421421
widgetPartial = new self.WidgetPartial( partialId, {
422422
params: {}
423423
} );
424424
}
425425

426+
// Build containers from the registered sidebar, since partial params can be declared in post content.
427+
sidebarArgs = _.findWhere( self.registeredSidebars, { id: sidebarPartial.sidebarId } );
428+
426429
// Make sure that there is a container element for the widget in the sidebar, if at least a placeholder.
427430
_.each( sidebarPartial.placements(), function( sidebarPlacement ) {
428431
var foundWidgetPlacement, widgetContainerElement;
429432

433+
if ( ! sidebarArgs ) {
434+
return;
435+
}
436+
430437
foundWidgetPlacement = _.find( widgetPartial.placements(), function( widgetPlacement ) {
431438
return ( widgetPlacement.context.sidebar_instance_number === sidebarPlacement.context.instanceNumber );
432439
} );
@@ -435,8 +442,8 @@ wp.customize.widgetsPreview = wp.customize.WidgetCustomizerPreview = (function(
435442
}
436443

437444
widgetContainerElement = $(
438-
sidebarPartial.params.sidebarArgs.before_widget.replace( /%1\$s/g, widgetId ).replace( /%2\$s/g, 'widget' ) +
439-
sidebarPartial.params.sidebarArgs.after_widget
445+
sidebarArgs.before_widget.replace( /%1\$s/g, widgetId ).replace( /%2\$s/g, 'widget' ) +
446+
sidebarArgs.after_widget
440447
);
441448

442449
// Handle rare case where before_widget and after_widget are empty.

‎src/js/_enqueues/wp/customize/selective-refresh.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ wp.customize.selectiveRefresh = ( function( $, api ) {
262262
if ( selector ) {
263263
selector += ', ';
264264
}
265-
selector += '[data-customize-partial-id="' + partial.id + '"]'; // @todo Consider injecting customize-partial-id-${id} classnames instead.
265+
selector += '[data-customize-partial-id="' + CSS.escape( partial.id ) + '"]';
266266

267-
return $( selector ).map( function() {
267+
return $( document ).find( selector ).map( function() {
268268
var container = $( this ), context;
269269

270270
context = container.data( 'customize-partial-placement-context' );

‎src/wp-admin/includes/ajax-actions.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1768,7 +1768,7 @@ function wp_ajax_add_user( $action ) {
17681768
'show-link' => sprintf(
17691769
/* translators: %s: The new user. */
17701770
__( 'User %s added' ),
1771-
'<a href="#user-' . $user_id . '">' . $user_object->user_login . '</a>'
1771+
'<a href="#user-' . $user_id . '">' . esc_html( $user_object->user_login ) . '</a>'
17721772
),
17731773
'role' => $role,
17741774
),

‎src/wp-admin/includes/class-wp-ms-users-list-table.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public function column_cb( $item ) {
240240
<span class="screen-reader-text">
241241
<?php
242242
/* translators: Hidden accessibility text. %s: User login. */
243-
printf( __( 'Select %s' ), $user->user_login );
243+
printf( __( 'Select %s' ), esc_html( $user->user_login ) );
244244
?>
245245
</span>
246246
</label>
@@ -273,9 +273,9 @@ public function column_username( $user ) {
273273

274274
if ( current_user_can( 'edit_user', $user->ID ) ) {
275275
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
276-
$edit = "<a href=\"{$edit_link}\">{$user->user_login}</a>";
276+
$edit = "<a href=\"{$edit_link}\">" . esc_html( $user->user_login ) . '</a>';
277277
} else {
278-
$edit = $user->user_login;
278+
$edit = esc_html( $user->user_login );
279279
}
280280

281281
?>

‎src/wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function column_email( $item ) {
9898
$row_actions['complete-request'] = $complete_request_markup;
9999
}
100100

101-
return sprintf( '<a href="%1$s">%2$s</a> %3$s', esc_url( 'mailto:' . $item->email ), $item->email, $this->row_actions( $row_actions ) );
101+
return sprintf( '<a href="%1$s">%2$s</a> %3$s', esc_url( 'mailto:' . $item->email ), esc_html( $item->email ), $this->row_actions( $row_actions ) );
102102
}
103103

104104
/**

‎src/wp-admin/includes/class-wp-privacy-data-removal-requests-list-table.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function column_email( $item ) {
104104
$row_actions['complete-request'] = $complete_request_markup;
105105
}
106106

107-
return sprintf( '<a href="%1$s">%2$s</a> %3$s', esc_url( 'mailto:' . $item->email ), $item->email, $this->row_actions( $row_actions ) );
107+
return sprintf( '<a href="%1$s">%2$s</a> %3$s', esc_url( 'mailto:' . $item->email ), esc_html( $item->email ), $this->row_actions( $row_actions ) );
108108
}
109109

110110
/**

‎src/wp-admin/includes/class-wp-privacy-requests-table.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ public function column_cb( $item ) {
420420
'<label for="requester_%1$s"><span class="screen-reader-text">%2$s</span></label><span class="spinner"></span>',
421421
esc_attr( $item->ID ),
422422
/* translators: Hidden accessibility text. %s: Email address. */
423-
sprintf( __( 'Select %s' ), $item->email )
423+
sprintf( __( 'Select %s' ), esc_html( $item->email ) )
424424
);
425425
}
426426

@@ -529,7 +529,7 @@ public function column_created_timestamp( $item ) {
529529
* @return string Email column markup.
530530
*/
531531
public function column_email( $item ) {
532-
return sprintf( '<a href="%1$s">%2$s</a> %3$s', esc_url( 'mailto:' . $item->email ), $item->email, $this->row_actions( array() ) );
532+
return sprintf( '<a href="%1$s">%2$s</a> %3$s', esc_url( 'mailto:' . $item->email ), esc_html( $item->email ), $this->row_actions( array() ) );
533533
}
534534

535535
/**

‎src/wp-admin/includes/class-wp-upgrader.php‎

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,21 @@ public function download_package( $package, $check_signatures = false, $hook_ext
339339
return $download_file;
340340
}
341341

342+
/**
343+
* Builds an unpredictable name for the directory a package is unpacked into.
344+
*
345+
* @since 7.1.4
346+
*
347+
* @param string $package The full local path or URI of the package.
348+
* @return string The directory name, without a path.
349+
*/
350+
private function get_working_dir_name( $package ) {
351+
// Strip off any .tmp or .zip suffixes.
352+
$name = basename( basename( $package, '.tmp' ), '.zip' );
353+
354+
return $name . '-' . wp_generate_password( 16, false );
355+
}
356+
342357
/**
343358
* Unpacks a compressed package file.
344359
*
@@ -362,16 +377,32 @@ public function unpack_package( $package, $delete_package = true ) {
362377

363378
$upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/';
364379

365-
// Clean up contents of upgrade directory beforehand.
380+
// Clean up contents of upgrade directory beforehand, keeping its index.php.
366381
$upgrade_files = $wp_filesystem->dirlist( $upgrade_folder );
367382
if ( ! empty( $upgrade_files ) ) {
368383
foreach ( $upgrade_files as $file ) {
384+
if ( 'index.php' === $file['name'] ) {
385+
continue;
386+
}
387+
369388
$wp_filesystem->delete( $upgrade_folder . $file['name'], true );
370389
}
371390
}
372391

373-
// We need a working directory - strip off any .tmp or .zip suffixes.
374-
$working_dir = $upgrade_folder . basename( basename( $package, '.tmp' ), '.zip' );
392+
/*
393+
* The upgrade directory is web-served. Keep it from being listed, as core does
394+
* for wp-content and its plugins and themes directories, so the name of the
395+
* working directory created below cannot be discovered from a directory index.
396+
*/
397+
if ( ! $wp_filesystem->is_dir( $upgrade_folder ) ) {
398+
$wp_filesystem->mkdir( $upgrade_folder, FS_CHMOD_DIR );
399+
}
400+
if ( ! $wp_filesystem->exists( $upgrade_folder . 'index.php' ) ) {
401+
$wp_filesystem->put_contents( $upgrade_folder . 'index.php', "<?php\n// Silence is golden.\n", FS_CHMOD_FILE );
402+
}
403+
404+
// We need a working directory.
405+
$working_dir = $upgrade_folder . $this->get_working_dir_name( $package );
375406

376407
// Clean up working directory.
377408
if ( $wp_filesystem->is_dir( $working_dir ) ) {

0 commit comments

Comments
 (0)