Skip to content

Commit e23fd7a

Browse files
committed
Allow OOB for out-of-band callbacks
See #28
1 parent 7b32d2e commit e23fd7a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/class-wp-rest-oauth1.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ public function set_request_token_callback( $key, $callback ) {
402402
}
403403

404404
$consumer = $token['consumer'];
405-
if ( ! $this->validate_callback( $callback ) || ! $this->check_callback( $callback, $consumer ) ) {
405+
if ( ! $this->check_callback( $callback, $consumer ) ) {
406406
return new WP_Error( 'json_oauth1_invalid_callback', __( 'Callback URL is invalid' ) );
407407
}
408408

@@ -457,6 +457,17 @@ public function check_callback( $url, $consumer_id ) {
457457
return false;
458458
}
459459

460+
// Out-of-band isn't a URL, but is still valid
461+
if ( $registered === 'oob' || $url === 'oob' ) {
462+
// Ensure both the registered URL and requested are 'oob'
463+
return ( $registered === $url );
464+
}
465+
466+
// Validate the supplied URL
467+
if ( ! $this->validate_callback( $url ) ) {
468+
return false;
469+
}
470+
460471
$registered = wp_parse_url( $registered );
461472
$supplied = wp_parse_url( $url );
462473

0 commit comments

Comments
 (0)