Make WordPress Core

Ticket #63137: 63137.3.patch

File 63137.3.patch, 6.1 KB (added by viralsampat, 5 weeks ago)

I have checked above mentioned issue and founds few files. Here, I have added its patch.

  • src/wp-includes/canonical.php

    diff --git src/wp-includes/canonical.php src/wp-includes/canonical.php
    index 58723ebc0d..52c04a8cdd 100644
    function redirect_canonical( $requested_url = null, $do_redirect = true ) { 
    6969                // Build the URL in the address bar.
    7070                $requested_url  = is_ssl() ? 'https://' : 'http://';
    7171                $requested_url .= $_SERVER['HTTP_HOST'];
    72                 $requested_url .= $_SERVER['REQUEST_URI'];
     72                $requested_url .= isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '';
    7373        }
    7474
    7575        $original = parse_url( $requested_url );
  • src/wp-includes/class-wp-xmlrpc-server.php

    diff --git src/wp-includes/class-wp-xmlrpc-server.php src/wp-includes/class-wp-xmlrpc-server.php
    index c5a4eba66e..f09798cf2a 100644
    class wp_xmlrpc_server extends IXR_Server { 
    48954895                        return $blogs;
    48964896                }
    48974897
    4898                 if ( $_SERVER['HTTP_HOST'] === $domain && $_SERVER['REQUEST_URI'] === $path ) {
     4898                if ( ( isset( $_SERVER['HTTP_HOST'] ) && $_SERVER['HTTP_HOST'] === $domain ) && ( isset( _SERVER['REQUEST_URI'] ) && $_SERVER['REQUEST_URI'] === $path ) ) {
    48994899                        return $blogs;
    49004900                } else {
    49014901                        foreach ( (array) $blogs as $blog ) {
  • src/wp-includes/class-wp.php

    diff --git src/wp-includes/class-wp.php src/wp-includes/class-wp.php
    index f2b114e708..19a58a1e73 100644
    class WP { 
    172172                        $pathinfo         = str_replace( '%', '%25', $pathinfo );
    173173
    174174                        list( $req_uri ) = explode( '?', $_SERVER['REQUEST_URI'] );
    175                         $self            = $_SERVER['PHP_SELF'];
     175                        $self            = isset( $_SERVER['PHP_SELF'] ) ? sanitize_text_field( wp_unslash( $_SERVER['PHP_SELF'] ) ) : '';
    176176
    177177                        $home_path       = parse_url( home_url(), PHP_URL_PATH );
    178178                        $home_path_regex = '';
  • src/wp-includes/load.php

    diff --git src/wp-includes/load.php src/wp-includes/load.php
    index 0526cb175d..7191f27609 100644
    function wp_fix_server_vars() { 
    6060
    6161                        // Some IIS + PHP configurations put the script-name in the path-info (no need to append it twice).
    6262                        if ( isset( $_SERVER['PATH_INFO'] ) ) {
    63                                 if ( $_SERVER['PATH_INFO'] === $_SERVER['SCRIPT_NAME'] ) {
     63                                if ( isset( $_SERVER['SCRIPT_NAME'] ) && $_SERVER['PATH_INFO'] === $_SERVER['SCRIPT_NAME'] ) {
    6464                                        $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
    6565                                } else {
    6666                                        $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
    function wp_fix_server_vars() { 
    6868                        }
    6969
    7070                        // Append the query string if it exists and isn't null.
    71                         if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
     71                        if ( isset( $_SERVER['QUERY_STRING'] ) && ! empty( $_SERVER['QUERY_STRING'] ) ) {
    7272                                $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
    7373                        }
    7474                }
    function wp_fix_server_vars() { 
    8585        }
    8686
    8787        // Fix empty PHP_SELF.
    88         $PHP_SELF = $_SERVER['PHP_SELF'];
     88        $PHP_SELF = isset( $_SERVER['PHP_SELF'] ) ? sanitize_text_field( wp_unslash( $_SERVER['PHP_SELF'] ) ) : '';
    8989        if ( empty( $PHP_SELF ) ) {
    9090                $_SERVER['PHP_SELF'] = preg_replace( '/(\?.*)?$/', '', $_SERVER['REQUEST_URI'] );
    91                 $PHP_SELF            = $_SERVER['PHP_SELF'];
     91                $PHP_SELF            = isset( $_SERVER['PHP_SELF'] ) ? sanitize_text_field( wp_unslash( $_SERVER['PHP_SELF'] ) ) : '';
    9292        }
    9393
    9494        wp_populate_basic_auth_from_authorization_header();
    function wp_is_development_mode( $mode ) { 
    379379 * @deprecated 5.4.0 Deprecated in favor of do_favicon().
    380380 */
    381381function wp_favicon_request() {
    382         if ( '/favicon.ico' === $_SERVER['REQUEST_URI'] ) {
     382        if ( isset( $_SERVER['REQUEST_URI'] ) && '/favicon.ico' === $_SERVER['REQUEST_URI'] ) {
    383383                header( 'Content-Type: image/vnd.microsoft.icon' );
    384384                exit;
    385385        }
  • src/wp-includes/ms-deprecated.php

    diff --git src/wp-includes/ms-deprecated.php src/wp-includes/ms-deprecated.php
    index 5a6b4415ed..3e5d23bc57 100644
    function get_blogaddress_by_domain( $domain, $path ) { 
    370370        if ( is_subdomain_install() ) {
    371371                $url = "http://" . $domain.$path;
    372372        } else {
    373                 if ( $domain != $_SERVER['HTTP_HOST'] ) {
     373                if ( isset( $_SERVER['HTTP_HOST'] ) && $domain != $_SERVER['HTTP_HOST'] ) {
    374374                        $blogname = substr( $domain, 0, strpos( $domain, '.' ) );
    375375                        $url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path;
    376376                        // We're not installing the main blog.
  • src/wp-includes/ms-settings.php

    diff --git src/wp-includes/ms-settings.php src/wp-includes/ms-settings.php
    index c665da17e3..818d692c58 100644
    ms_subdomain_constants(); 
    5959// have not been populated in the global scope through something like `sunrise.php`.
    6060if ( ! isset( $current_site ) || ! isset( $current_blog ) ) {
    6161
    62         $domain = strtolower( stripslashes( $_SERVER['HTTP_HOST'] ) );
     62        $domain = isset( $_SERVER['HTTP_HOST'] ) ? strtolower( stripslashes( $_SERVER['HTTP_HOST'] ) ) : '';
    6363        if ( str_ends_with( $domain, ':80' ) ) {
    6464                $domain               = substr( $domain, 0, -3 );
    65                 $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 );
     65                $_SERVER['HTTP_HOST'] = isset( $_SERVER['HTTP_HOST'] ) ? substr( $_SERVER['HTTP_HOST'], 0, -3 ) : '';
    6666        } elseif ( str_ends_with( $domain, ':443' ) ) {
    6767                $domain               = substr( $domain, 0, -4 );
    68                 $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 );
     68                $_SERVER['HTTP_HOST'] = isset( $_SERVER['HTTP_HOST'] ) ? substr( $_SERVER['HTTP_HOST'], 0, -4 ) : '';
    6969        }
    7070
    7171        $path = stripslashes( $_SERVER['REQUEST_URI'] );
  • src/wp-includes/theme-previews.php

    diff --git src/wp-includes/theme-previews.php src/wp-includes/theme-previews.php
    index 7e0c085b1c..eaff5a0525 100644
    function wp_block_theme_activate_nonce() { 
    8484 * @since 6.3.2
    8585 */
    8686function wp_initialize_theme_preview_hooks() {
    87         if ( ! empty( $_GET['wp_theme_preview'] ) ) {
     87        if ( isset( $_GET['wp_theme_preview'] ) && ! empty( $_GET['wp_theme_preview'] ) ) {
    8888                add_filter( 'stylesheet', 'wp_get_theme_preview_path' );
    8989                add_filter( 'template', 'wp_get_theme_preview_path' );
    9090                add_action( 'init', 'wp_attach_theme_preview_middleware' );