Make WordPress Core

Ticket #17177: 17177.2.diff

File 17177.2.diff, 2.8 KB (added by duck_, 15 years ago)
  • wp-includes/class-wp.php

     
    185185
    186186                        // Look for matches.
    187187                        $request_match = $request;
    188                         foreach ( (array) $rewrite as $match => $query) {
    189                                 // Don't try to match against AtomPub calls
    190                                 if ( $req_uri == 'wp-app.php' )
    191                                         break;
     188                        if ( empty( $req_uri ) ) {
     189                                if ( isset( $rewrite['$'] ) ) {
     190                                        $this->matched_rule = '$';
     191                                        $query = $rewrite['$'];
     192                                        $matches = array('');
     193                                }
     194                        } else if ( $req_uri != 'wp-app.php' ) {
     195                                foreach ( (array) $rewrite as $match => $query ) {
     196                                        // If the requesting file is the anchor of the match, prepend it to the path info.
     197                                        if ( ! empty($req_uri) && strpos($match, $req_uri) === 0 && $req_uri != $request )
     198                                                $request_match = $req_uri . '/' . $request;
    192199
    193                                 // If the requesting file is the anchor of the match, prepend it
    194                                 // to the path info.
    195                                 if ( (! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request) )
    196                                         $request_match = $req_uri . '/' . $request;
     200                                        if ( preg_match("#^$match#", $request_match, $matches) ||
     201                                                preg_match("#^$match#", urldecode($request_match), $matches) ) {
     202                                                // Got a match.
     203                                                $this->matched_rule = $match;
     204                                                break;
     205                                        }
     206                                }
     207                        }
    197208
    198                                 if ( preg_match("#^$match#", $request_match, $matches) ||
    199                                         preg_match("#^$match#", urldecode($request_match), $matches) ) {
    200                                         // Got a match.
    201                                         $this->matched_rule = $match;
     209                        if ( isset( $this->matched_rule ) ) {
     210                                // Trim the query of everything up to the '?'.
     211                                $query = preg_replace("!^.+\?!", '', $query);
    202212
    203                                         // Trim the query of everything up to the '?'.
    204                                         $query = preg_replace("!^.+\?!", '', $query);
     213                                // Substitute the substring matches into the query.
     214                                $query = addslashes(WP_MatchesMapRegex::apply($query, $matches));
    205215
    206                                         // Substitute the substring matches into the query.
    207                                         $query = addslashes(WP_MatchesMapRegex::apply($query, $matches));
     216                                $this->matched_query = $query;
    208217
    209                                         $this->matched_query = $query;
     218                                // Parse the query.
     219                                parse_str($query, $perma_query_vars);
    210220
    211                                         // Parse the query.
    212                                         parse_str($query, $perma_query_vars);
     221                                // If we're processing a 404 request, clear the error var
     222                                // since we found something.
     223                                if ( isset($_GET['error']) )
     224                                        unset($_GET['error']);
    213225
    214                                         // If we're processing a 404 request, clear the error var
    215                                         // since we found something.
    216                                         if ( isset($_GET['error']) )
    217                                                 unset($_GET['error']);
    218 
    219                                         if ( isset($error) )
    220                                                 unset($error);
    221 
    222                                         break;
    223                                 }
     226                                if ( isset($error) )
     227                                        unset($error);
    224228                        }
    225229
    226230                        // If req_uri is empty or if it is a request for ourself, unset error.