Make WordPress Core

Changeset 61957


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

Grouped backports for the 5.3 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.3 branch.

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

Location:
branches/5.3
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/5.3

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

    r43347 r61957  
    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.3/src/wp-admin/includes/class-walker-nav-menu-checklist.php

    r46843 r61957  
    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.3/src/wp-admin/includes/class-walker-nav-menu-edit.php

    r45932 r61957  
    193193                    <label for="edit-menu-item-title-<?php echo $item_id; ?>">
    194194                        <?php _e( 'Navigation Label' ); ?><br />
    195                         <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 ); ?>" />
     195                        <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 ); ?>" />
    196196                    </label>
    197197                </p>
     
    199199                    <label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
    200200                        <?php _e( 'Title Attribute' ); ?><br />
    201                         <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 ); ?>" />
     201                        <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 ); ?>" />
    202202                    </label>
    203203                </p>
     
    211211                    <label for="edit-menu-item-classes-<?php echo $item_id; ?>">
    212212                        <?php _e( 'CSS Classes (optional)' ); ?><br />
    213                         <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 ) ); ?>" />
     213                        <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 ); ?>" />
    214214                    </label>
    215215                </p>
     
    217217                    <label for="edit-menu-item-xfn-<?php echo $item_id; ?>">
    218218                        <?php _e( 'Link Relationship (XFN)' ); ?><br />
    219                         <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 ); ?>" />
     219                        <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 ); ?>" />
    220220                    </label>
    221221                </p>
  • branches/5.3/src/wp-admin/includes/file.php

    r46400 r61957  
    16161616        }
    16171617
     1618        // Don't extract invalid files:
     1619        if ( 0 !== validate_file( $file['filename'] ) ) {
     1620            continue;
     1621        }
     1622
    16181623        $uncompressed_size += $file['size'];
    16191624
  • branches/5.3/src/wp-includes/ID3/getid3.lib.php

    r46112 r61957  
    727727            // https://core.trac.wordpress.org/changeset/29378
    728728            $loader = libxml_disable_entity_loader(true);
    729             $XMLobject = simplexml_load_string($XMLstring, 'SimpleXMLElement', LIBXML_NOENT);
     729            $XMLobject = simplexml_load_string($XMLstring, 'SimpleXMLElement', 0);
    730730            $return = self::SimpleXMLelement2array($XMLobject);
    731731            libxml_disable_entity_loader($loader);
  • branches/5.3/src/wp-includes/class-wp-http-ixr-client.php

    r42876 r61957  
    8686        }
    8787
    88         $response = wp_remote_post( $url, $args );
     88        $response = wp_safe_remote_post( $url, $args );
    8989
    9090        if ( is_wp_error( $response ) ) {
  • branches/5.3/src/wp-includes/kses.php

    r46899 r61957  
    17351735    $string = str_replace( '&', '&amp;', $string );
    17361736
    1737     // Change back the allowed entities in our entity whitelist
    17381737    $string = preg_replace_callback( '/&amp;([A-Za-z]{2,8}[0-9]{0,2});/', 'wp_kses_named_entities', $string );
    1739     $string = preg_replace_callback( '/&amp;#(0*[0-9]{1,7});/', 'wp_kses_normalize_entities2', $string );
    1740     $string = preg_replace_callback( '/&amp;#[Xx](0*[0-9A-Fa-f]{1,6});/', 'wp_kses_normalize_entities3', $string );
     1738    $string = preg_replace_callback( '/&amp;#(0*[1-9][0-9]{0,6});/', 'wp_kses_normalize_entities2', $string );
     1739    $string = preg_replace_callback( '/&amp;#[Xx](0*[1-9A-Fa-f][0-9A-Fa-f]{0,5});/', 'wp_kses_normalize_entities3', $string );
    17411740
    17421741    return $string;
  • branches/5.3/src/wp-includes/media.php

    r56877 r61957  
    34393439    }
    34403440
    3441     if ( $post_parent ) {
     3441    if ( $post_parent && current_user_can( 'read_post', $attachment->post_parent ) ) {
    34423442        $parent_type = get_post_type_object( $post_parent->post_type );
    34433443
     
    34463446        }
    34473447
    3448         if ( $parent_type && current_user_can( 'read_post', $attachment->post_parent ) ) {
     3448        if ( $parent_type ) {
    34493449            $response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __( '(no title)' );
    34503450        }
  • branches/5.3/src/wp-includes/nav-menu.php

    r46104 r61957  
    492492        }
    493493
    494         if ( $args['menu-item-title'] == $original_title ) {
     494        if ( wp_unslash( $args['menu-item-title'] ) === $original_title ) {
    495495            $args['menu-item-title'] = '';
    496496        }
  • branches/5.3/src/wp-includes/template-loader.php

    r45590 r61957  
    9494     * @param string $template The path of the template to include.
    9595     */
    96     $template = apply_filters( 'template_include', $template );
    97     if ( $template ) {
    98         include( $template );
     96    $template   = apply_filters( 'template_include', $template );
     97    $is_stringy = is_string( $template ) || ( is_object( $template ) && method_exists( $template, '__toString' ) );
     98    $template   = $is_stringy ? realpath( (string) $template ) : null;
     99    if (
     100        is_string( $template ) &&
     101        ( str_ends_with( $template, '.php' ) || str_ends_with( $template, '.html' ) ) &&
     102        is_file( $template ) &&
     103        is_readable( $template )
     104    ) {
     105        include $template;
    99106    } elseif ( current_user_can( 'switch_themes' ) ) {
    100107        $theme = wp_get_theme();
  • branches/5.3/tests/phpunit/tests/post/nav-menu.php

    r46414 r61957  
    957957    }
    958958
     959    /**
     960     * Tests `wp_update_nav_menu_item()` with special characters in a category name.
     961     *
     962     * When inserting a category as a nav item, the `post_title` property should
     963     * be empty, as the item should get the title from the category object itself.
     964     *
     965     * @ticket 48011
     966     */
     967    function test_wp_update_nav_menu_item_with_special_characters_in_category_name() {
     968        $category_name = 'Test Cat - \"Pre-Slashed\" Cat Name & >';
     969
     970        $category = self::factory()->category->create_and_get(
     971            array(
     972                'name' => $category_name,
     973            )
     974        );
     975
     976        $this->assertSame( 'Test Cat - "Pre-Slashed" Cat Name &amp; &gt;', $category->name );
     977
     978        $category_item_id = wp_update_nav_menu_item(
     979            $this->menu_id,
     980            0,
     981            array(
     982                'menu-item-type'      => 'taxonomy',
     983                'menu-item-object'    => 'category',
     984                'menu-item-object-id' => $category->term_id,
     985                'menu-item-status'    => 'publish',
     986                'menu-item-title'     => $category->name,
     987            )
     988        );
     989
     990        $category_item = get_post( $category_item_id );
     991        $this->assertEmpty( $category_item->post_title );
     992    }
    959993}
Note: See TracChangeset for help on using the changeset viewer.