@@ -100,7 +100,7 @@ public function register_routes() {
100100 $ args = array (
101101 'methods ' => WP_REST_Server::READABLE ,
102102 'callback ' => array ( $ this , 'validate ' ),
103- 'permission_callback ' => '__return_true '
103+ 'permission_callback ' => '__return_true ' ,
104104 );
105105 register_rest_route ( self ::_NAMESPACE_ , '/ ' . self ::_REST_BASE_ . '/validate ' , $ args );
106106
@@ -109,13 +109,13 @@ public function register_routes() {
109109 'callback ' => array ( $ this , 'generate_token ' ),
110110 'permission_callback ' => '__return_true ' ,
111111 'args ' => array (
112- 'api_key ' => array (
112+ 'api_key ' => array (
113113 'description ' => __ ( 'The API key of the user; requires also setting the api_secret. ' , 'jwt-auth ' ),
114114 'type ' => 'string ' ,
115115 'sanitize_callback ' => 'sanitize_text_field ' ,
116116 'validate_callback ' => 'rest_validate_request_arg ' ,
117117 ),
118- 'api_secret ' => array (
118+ 'api_secret ' => array (
119119 'description ' => __ ( 'The API secret of the user; requires also setting the api_key. ' , 'jwt-auth ' ),
120120 'type ' => 'string ' ,
121121 'sanitize_callback ' => 'sanitize_text_field ' ,
@@ -382,8 +382,8 @@ public function authenticate_refresh_token( $user, WP_REST_Request $request ) {
382382 */
383383 public function require_token () {
384384 $ 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 ;
387387
388388 // User is already authenticated.
389389 $ user = wp_get_current_user ();
@@ -777,11 +777,11 @@ public function validate_token() {
777777 public function get_auth_header () {
778778
779779 // 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 ;
781781
782782 // Check for alternative header.
783783 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 ' ] ) );
785785 }
786786
787787 // The HTTP Authorization Header is missing, return an error.
0 commit comments