Skip to content

Commit aa58a94

Browse files
committed
Security: Backport the WordPress 7.1.4 security fixes to the 6.7 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. - Interactivity API: Limit bindings on object elements to global attributes - 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 - Categories block: Don't run the dropdown label through sprintf() - 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@9.8.19, @wordpress/block-serialization-default-parser@5.8.2, @wordpress/interactivity@6.8.7, @wordpress/interactivity-router@2.8.8. Merges [64873], [64874], [64876], [64877], [64878], [64879] to the 6.7 branch. Props xknown, jeremyfelt, jorbin, rfaile313, westonruter, jonsurrell, dmsnell, lancewillett, umut3806, marcs0h, ntsekouras, luisherranz, santosguillamot, darerodz, johnbillion. git-svn-id: https://develop.svn.wordpress.org/branches/6.7@64898 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 0e807c4 commit aa58a94

29 files changed

Lines changed: 289 additions & 75 deletions

‎package-lock.json‎

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

‎package.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@
8686
"@wordpress/blob": "4.8.1",
8787
"@wordpress/block-directory": "5.8.19",
8888
"@wordpress/block-editor": "14.3.16",
89-
"@wordpress/block-library": "9.8.18",
90-
"@wordpress/block-serialization-default-parser": "5.8.1",
89+
"@wordpress/block-library": "9.8.19",
90+
"@wordpress/block-serialization-default-parser": "5.8.2",
9191
"@wordpress/blocks": "13.8.6",
9292
"@wordpress/commands": "1.8.12",
9393
"@wordpress/components": "28.8.12",
@@ -114,8 +114,8 @@
114114
"@wordpress/html-entities": "4.8.1",
115115
"@wordpress/i18n": "5.8.2",
116116
"@wordpress/icons": "10.8.2",
117-
"@wordpress/interactivity": "6.8.6",
118-
"@wordpress/interactivity-router": "2.8.7",
117+
"@wordpress/interactivity": "6.8.7",
118+
"@wordpress/interactivity-router": "2.8.8",
119119
"@wordpress/interface": "6.8.12",
120120
"@wordpress/is-shallow-equal": "5.8.1",
121121
"@wordpress/keyboard-shortcuts": "5.8.4",

‎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
@@ -1777,7 +1777,7 @@ function wp_ajax_add_user( $action ) {
17771777
'show-link' => sprintf(
17781778
/* translators: %s: The new user. */
17791779
__( 'User %s added' ),
1780-
'<a href="#user-' . $user_id . '">' . $user_object->user_login . '</a>'
1780+
'<a href="#user-' . $user_id . '">' . esc_html( $user_object->user_login ) . '</a>'
17811781
),
17821782
'role' => $role,
17831783
),

‎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
@@ -341,6 +341,21 @@ public function download_package( $package, $check_signatures = false, $hook_ext
341341
return $download_file;
342342
}
343343

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

365380
$upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/';
366381

367-
// Clean up contents of upgrade directory beforehand.
382+
// Clean up contents of upgrade directory beforehand, keeping its index.php.
368383
$upgrade_files = $wp_filesystem->dirlist( $upgrade_folder );
369384
if ( ! empty( $upgrade_files ) ) {
370385
foreach ( $upgrade_files as $file ) {
386+
if ( 'index.php' === $file['name'] ) {
387+
continue;
388+
}
389+
371390
$wp_filesystem->delete( $upgrade_folder . $file['name'], true );
372391
}
373392
}
374393

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

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

0 commit comments

Comments
 (0)