Skip to content

Commit 3872b95

Browse files
authored
Merge pull request #154 from WP-API/urlencode-arrays
Fix creating signature with arrays in the URL
2 parents 5c10e90 + cc9f7f9 commit 3872b95

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/class-wp-rest-oauth1.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ public function check_oauth_signature( $consumer, $oauth_params, $token = null )
662662
if ( substr( $request_path, 0, strlen( $wp_base ) ) === $wp_base ) {
663663
$request_path = substr( $request_path, strlen( $wp_base ) );
664664
}
665-
$base_request_uri = rawurlencode( get_home_url( null, $request_path ) );
665+
$base_request_uri = self::urlencode_rfc3986( get_home_url( null, $request_path ) );
666666

667667
// get the signature provided by the consumer and remove it from the parameters prior to checking the signature
668668
$consumer_signature = rawurldecode( $params['oauth_signature'] );
@@ -733,10 +733,10 @@ public function join_with_equals_sign( $params, $query_params = array(), $key =
733733
$query_params = $this->join_with_equals_sign( $param_value, $query_params, $param_key );
734734
} else {
735735
if ( $key ) {
736-
$param_key = $key . '[' . $param_key . ']'; // Handle multi-dimensional array
736+
$param_key = $key . '%5B' . $param_key . '%5D'; // Handle multi-dimensional array
737737
}
738738
$string = $param_key . '=' . $param_value; // join with equals sign
739-
$query_params[] = urlencode( $string );
739+
$query_params[] = self::urlencode_rfc3986($string );
740740
}
741741
}
742742
return $query_params;
@@ -752,8 +752,8 @@ public function join_with_equals_sign( $params, $query_params = array(), $key =
752752
* @param string $value
753753
*/
754754
protected function normalize_parameters( &$key, &$value ) {
755-
$key = rawurlencode( rawurldecode( $key ) );
756-
$value = rawurlencode( rawurldecode( $value ) );
755+
$key = self::urlencode_rfc3986( rawurldecode( $key ) );
756+
$value = self::urlencode_rfc3986( rawurldecode( $value ) );
757757
}
758758

759759
/**

0 commit comments

Comments
 (0)