Skip to content

Commit f8fa82d

Browse files
committed
Merge pull request #78 from thiago-negri/master
Fix signature check for sub-folder WP installs
2 parents d380667 + 83f5a99 commit f8fa82d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/class-wp-json-authentication-oauth1.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,12 @@ protected function check_oauth_signature( $consumer, $oauth_params, $token = nul
551551

552552
$params = array_merge( $params, $oauth_params );
553553

554-
$base_request_uri = rawurlencode( get_home_url( null, parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ) ) );
554+
$request_path = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
555+
$wp_base = get_home_url( null, '/', 'relative' );
556+
if ( substr( $request_path, 0, strlen( $wp_base ) ) === $wp_base ) {
557+
$request_path = substr( $request_path, strlen( $wp_base ) );
558+
}
559+
$base_request_uri = rawurlencode( get_home_url( null, $request_path ) );
555560

556561
// get the signature provided by the consumer and remove it from the parameters prior to checking the signature
557562
$consumer_signature = rawurldecode( $params['oauth_signature'] );

0 commit comments

Comments
 (0)