WordPress.org

Make WordPress Core

Ticket #18165: 18165.1.patch

File 18165.1.patch, 1.5 KB (added by kurtpayne, 2 years ago)

No cgi.fix_pathinfo = 1 and no regex

  • wp-includes/load.php

     
    7878                } 
    7979        } 
    8080 
    81         // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests 
    82         if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) 
     81        // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php*.cgi for all requests 
     82        if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( 'php' == substr(basename($_SERVER['SCRIPT_FILENAME']), 0, 3) && '.cgi' == substr(basename($_SERVER['SCRIPT_FILENAME']), -4) ) ) 
    8383                $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; 
    8484 
    85         // Fix for Dreamhost and other PHP as CGI hosts 
    86         if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) 
     85        // Fix for Dreamhost and other PHP as CGI hosts (looks for $_SERVER['SCRIPT_NAME'] = "php*.cgi") 
     86        if ( 'php' == substr(basename($_SERVER['SCRIPT_NAME']), 0, 3) && '.cgi' == substr(basename($_SERVER['SCRIPT_NAME']), -4) ) 
    8787                unset( $_SERVER['PATH_INFO'] ); 
    8888 
     89        // Fix php.cgi as PHP_SELF (looks for $_SERVER['PHP_SELF'] = "php*.cgi") 
     90        if ( 'php' == substr(basename($_SERVER['PHP_SELF']), 0, 3) && '.cgi' == substr(basename($_SERVER['PHP_SELF']), -4) ) 
     91                $_SERVER['PHP_SELF'] = ''; 
     92         
    8993        // Fix empty PHP_SELF 
    9094        $PHP_SELF = $_SERVER['PHP_SELF']; 
    9195        if ( empty( $PHP_SELF ) )