@@ -100,7 +100,7 @@ public function register_routes() {
100
100
$ args = array (
101
101
'methods ' => WP_REST_Server::READABLE ,
102
102
'callback ' => array ( $ this , 'validate ' ),
103
- 'permission_callback ' => '__return_true '
103
+ 'permission_callback ' => '__return_true ' ,
104
104
);
105
105
register_rest_route ( self ::_NAMESPACE_ , '/ ' . self ::_REST_BASE_ . '/validate ' , $ args );
106
106
@@ -109,13 +109,13 @@ public function register_routes() {
109
109
'callback ' => array ( $ this , 'generate_token ' ),
110
110
'permission_callback ' => '__return_true ' ,
111
111
'args ' => array (
112
- 'api_key ' => array (
112
+ 'api_key ' => array (
113
113
'description ' => __ ( 'The API key of the user; requires also setting the api_secret. ' , 'jwt-auth ' ),
114
114
'type ' => 'string ' ,
115
115
'sanitize_callback ' => 'sanitize_text_field ' ,
116
116
'validate_callback ' => 'rest_validate_request_arg ' ,
117
117
),
118
- 'api_secret ' => array (
118
+ 'api_secret ' => array (
119
119
'description ' => __ ( 'The API secret of the user; requires also setting the api_key. ' , 'jwt-auth ' ),
120
120
'type ' => 'string ' ,
121
121
'sanitize_callback ' => 'sanitize_text_field ' ,
@@ -382,8 +382,8 @@ public function authenticate_refresh_token( $user, WP_REST_Request $request ) {
382
382
*/
383
383
public function require_token () {
384
384
$ require_token = true ;
385
- $ request_uri = isset ( $ _SERVER ['REQUEST_URI ' ] ) ? sanitize_text_field ( $ _SERVER ['REQUEST_URI ' ] ) : false ;
386
- $ request_method = isset ( $ _SERVER ['REQUEST_METHOD ' ] ) ? sanitize_text_field ( $ _SERVER ['REQUEST_METHOD ' ] ) : false ;
385
+ $ request_uri = isset ( $ _SERVER ['REQUEST_URI ' ] ) ? sanitize_text_field ( wp_unslash ( $ _SERVER ['REQUEST_URI ' ] ) ) : false ;
386
+ $ request_method = isset ( $ _SERVER ['REQUEST_METHOD ' ] ) ? sanitize_text_field ( wp_unslash ( $ _SERVER ['REQUEST_METHOD ' ] ) ) : false ;
387
387
388
388
// User is already authenticated.
389
389
$ user = wp_get_current_user ();
@@ -777,11 +777,11 @@ public function validate_token() {
777
777
public function get_auth_header () {
778
778
779
779
// Get HTTP Authorization Header.
780
- $ header = isset ( $ _SERVER ['HTTP_AUTHORIZATION ' ] ) ? sanitize_text_field ( $ _SERVER ['HTTP_AUTHORIZATION ' ] ) : false ;
780
+ $ header = isset ( $ _SERVER ['HTTP_AUTHORIZATION ' ] ) ? sanitize_text_field ( wp_unslash ( $ _SERVER ['HTTP_AUTHORIZATION ' ] ) ) : false ;
781
781
782
782
// Check for alternative header.
783
783
if ( ! $ header && isset ( $ _SERVER ['REDIRECT_HTTP_AUTHORIZATION ' ] ) ) {
784
- $ header = sanitize_text_field ( $ _SERVER ['REDIRECT_HTTP_AUTHORIZATION ' ] );
784
+ $ header = sanitize_text_field ( wp_unslash ( $ _SERVER ['REDIRECT_HTTP_AUTHORIZATION ' ] ) );
785
785
}
786
786
787
787
// The HTTP Authorization Header is missing, return an error.
0 commit comments