Make WordPress Core

Changeset 61952


Ignore:
Timestamp:
03/12/2026 02:02:42 AM (2 weeks ago)
Author:
peterwilsoncc
Message:

Grouped backports for the 5.8 branch.

  • XML-RPC: Switch to wp_safe_remote() when fetching a pingback URL.
  • HTML API: Prevent WP_HTML_Tag_Processor instances being unserialized and add some extra logic for validating pattern and template file paths.
  • KSES: Optimize PCRE pattern detecting numeric character references.
  • Customize: Improve escaping approach used for nav menu attributes.
  • Media: Ensure the attachment parent is accessible to the user before showing a link to it in the media manager.
  • Administration: Ensure client-side templates are only detected when they're correctly associated with a script tag.
  • Filesystem API: Don't attempt to extract invalid files from a zip when using the PclZip library.

Merges [61879-61885,61887,61890,61913] to the 5.8 branch.

Props johnbillion, xknown, dmsnell, jorbin, peterwilson, desrosj, westonruter, jonsurrell, aurdasjb.

Location:
branches/5.8
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/5.8

  • branches/5.8/src/js/_enqueues/wp/util.js

    r51238 r61952  
    3737
    3838        return function ( data ) {
    39             compiled = compiled || _.template( $( '#tmpl-' + id ).html(),  options );
     39            var el = document.querySelector( 'script#tmpl-' + id );
     40            if ( ! el ) {
     41                throw new Error( 'Template not found: ' + '#tmpl-' + id );
     42            }
     43            compiled = compiled || _.template( $( el ).html(), options );
    4044            return compiled( data );
    4145        };
  • branches/5.8/src/wp-admin/includes/class-walker-nav-menu-checklist.php

    r49936 r61952  
    112112        $output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item[' . $possible_object_id . '][menu-item-parent-id]" value="' . esc_attr( $item->menu_item_parent ) . '" />';
    113113        $output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="' . esc_attr( $item->type ) . '" />';
    114         $output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="' . esc_attr( $item->title ) . '" />';
     114        $output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="' . htmlspecialchars( $item->title, ENT_QUOTES ) . '" />';
    115115        $output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="' . esc_attr( $item->url ) . '" />';
    116116        $output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="' . esc_attr( $item->target ) . '" />';
    117         $output .= '<input type="hidden" class="menu-item-attr-title" name="menu-item[' . $possible_object_id . '][menu-item-attr-title]" value="' . esc_attr( $item->attr_title ) . '" />';
    118         $output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="' . esc_attr( implode( ' ', $item->classes ) ) . '" />';
    119         $output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="' . esc_attr( $item->xfn ) . '" />';
     117        $output .= '<input type="hidden" class="menu-item-attr-title" name="menu-item[' . $possible_object_id . '][menu-item-attr-title]" value="' . htmlspecialchars( $item->attr_title, ENT_QUOTES ) . '" />';
     118        $output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="' . htmlspecialchars( implode( ' ', $item->classes ), ENT_QUOTES ) . '" />';
     119        $output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="' . htmlspecialchars( $item->xfn, ENT_QUOTES ) . '" />';
    120120    }
    121121
  • branches/5.8/src/wp-admin/includes/class-walker-nav-menu-edit.php

    r51010 r61952  
    197197                    <label for="edit-menu-item-title-<?php echo $item_id; ?>">
    198198                        <?php _e( 'Navigation Label' ); ?><br />
    199                         <input type="text" id="edit-menu-item-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-title" name="menu-item-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->title ); ?>" />
     199                        <input type="text" id="edit-menu-item-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-title" name="menu-item-title[<?php echo $item_id; ?>]" value="<?php echo htmlspecialchars( $item->title, ENT_QUOTES ); ?>" />
    200200                    </label>
    201201                </p>
     
    203203                    <label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
    204204                        <?php _e( 'Title Attribute' ); ?><br />
    205                         <input type="text" id="edit-menu-item-attr-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->post_excerpt ); ?>" />
     205                        <input type="text" id="edit-menu-item-attr-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title[<?php echo $item_id; ?>]" value="<?php echo htmlspecialchars( $item->post_excerpt, ENT_QUOTES ); ?>" />
    206206                    </label>
    207207                </p>
     
    215215                    <label for="edit-menu-item-classes-<?php echo $item_id; ?>">
    216216                        <?php _e( 'CSS Classes (optional)' ); ?><br />
    217                         <input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr( implode( ' ', $item->classes ) ); ?>" />
     217                        <input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo htmlspecialchars( implode( ' ', $item->classes ), ENT_QUOTES ); ?>" />
    218218                    </label>
    219219                </p>
     
    221221                    <label for="edit-menu-item-xfn-<?php echo $item_id; ?>">
    222222                        <?php _e( 'Link Relationship (XFN)' ); ?><br />
    223                         <input type="text" id="edit-menu-item-xfn-<?php echo $item_id; ?>" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->xfn ); ?>" />
     223                        <input type="text" id="edit-menu-item-xfn-<?php echo $item_id; ?>" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php echo $item_id; ?>]" value="<?php echo htmlspecialchars( $item->xfn, ENT_QUOTES ); ?>" />
    224224                    </label>
    225225                </p>
  • branches/5.8/src/wp-admin/includes/file.php

    r50979 r61952  
    17291729        }
    17301730
     1731        // Don't extract invalid files:
     1732        if ( 0 !== validate_file( $file['filename'] ) ) {
     1733            continue;
     1734        }
     1735
    17311736        $uncompressed_size += $file['size'];
    17321737
  • branches/5.8/src/wp-includes/ID3/getid3.lib.php

    r50714 r61952  
    724724            // https://core.trac.wordpress.org/changeset/29378
    725725            // This function has been deprecated in PHP 8.0 because in libxml 2.9.0, external entity loading is
    726             // disabled by default, but is still needed when LIBXML_NOENT is used.
     726            // disabled by default.
    727727            $loader = @libxml_disable_entity_loader(true);
    728             $XMLobject = simplexml_load_string($XMLstring, 'SimpleXMLElement', LIBXML_NOENT);
     728            $XMLobject = simplexml_load_string($XMLstring, 'SimpleXMLElement', 0);
    729729            $return = self::SimpleXMLelement2array($XMLobject);
    730730            @libxml_disable_entity_loader($loader);
  • branches/5.8/src/wp-includes/class-wp-http-ixr-client.php

    r49927 r61952  
    8989        }
    9090
    91         $response = wp_remote_post( $url, $args );
     91        $response = wp_safe_remote_post( $url, $args );
    9292
    9393        if ( is_wp_error( $response ) ) {
  • branches/5.8/src/wp-includes/kses.php

    r51007 r61952  
    18071807        $string = preg_replace_callback( '/&amp;([A-Za-z]{2,8}[0-9]{0,2});/', 'wp_kses_named_entities', $string );
    18081808    }
    1809     $string = preg_replace_callback( '/&amp;#(0*[0-9]{1,7});/', 'wp_kses_normalize_entities2', $string );
    1810     $string = preg_replace_callback( '/&amp;#[Xx](0*[0-9A-Fa-f]{1,6});/', 'wp_kses_normalize_entities3', $string );
     1809    $string = preg_replace_callback( '/&amp;#(0*[1-9][0-9]{0,6});/', 'wp_kses_normalize_entities2', $string );
     1810    $string = preg_replace_callback( '/&amp;#[Xx](0*[1-9A-Fa-f][0-9A-Fa-f]{0,5});/', 'wp_kses_normalize_entities3', $string );
    18111811
    18121812    return $string;
  • branches/5.8/src/wp-includes/media.php

    r56884 r61952  
    40424042    if ( $attachment->post_parent ) {
    40434043        $post_parent = get_post( $attachment->post_parent );
    4044         if ( $post_parent ) {
     4044        if ( $post_parent && current_user_can( 'read_post', $attachment->post_parent ) ) {
    40454045            $response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __( '(no title)' );
    40464046            $response['uploadedToLink']  = get_edit_post_link( $attachment->post_parent, 'raw' );
  • branches/5.8/src/wp-includes/nav-menu.php

    r50828 r61952  
    495495        }
    496496
    497         if ( wp_unslash( $args['menu-item-title'] ) === wp_specialchars_decode( $original_title ) ) {
     497        if ( wp_unslash( $args['menu-item-title'] ) === $original_title ) {
    498498            $args['menu-item-title'] = '';
    499499        }
  • branches/5.8/src/wp-includes/template-loader.php

    r47855 r61952  
    102102     * @param string $template The path of the template to include.
    103103     */
    104     $template = apply_filters( 'template_include', $template );
    105     if ( $template ) {
     104    $template   = apply_filters( 'template_include', $template );
     105    $is_stringy = is_string( $template ) || ( is_object( $template ) && method_exists( $template, '__toString' ) );
     106    $template   = $is_stringy ? realpath( (string) $template ) : null;
     107    if (
     108        is_string( $template ) &&
     109        ( str_ends_with( $template, '.php' ) || str_ends_with( $template, '.html' ) ) &&
     110        is_file( $template ) &&
     111        is_readable( $template )
     112    ) {
    106113        include $template;
    107114    } elseif ( current_user_can( 'switch_themes' ) ) {
  • branches/5.8/tests/phpunit/tests/post/nav-menu.php

    r50284 r61952  
    974974        );
    975975
     976        $this->assertSame( 'Test Cat - "Pre-Slashed" Cat Name &amp; &gt;', $category->name );
     977
    976978        $category_item_id = wp_update_nav_menu_item(
    977979            $this->menu_id,
     
    982984                'menu-item-object-id' => $category->term_id,
    983985                'menu-item-status'    => 'publish',
    984                 /*
    985                  * Interestingly enough, if we use `$cat->name` for the menu item title,
    986                  * we won't be able to replicate the bug because it's in htmlentities form.
    987                  */
    988                 'menu-item-title'     => $category_name,
     986                'menu-item-title'     => $category->name,
    989987            )
    990988        );
Note: See TracChangeset for help on using the changeset viewer.