@@ -174,42 +174,58 @@ public function check_redirect_uri( $uri ) {
174
174
}
175
175
176
176
$ supplied = wp_parse_url ( $ uri );
177
+ $ all_registered = $ this ->get_redirect_uris ();
177
178
178
- // Check all components except query and fragment
179
- $ parts = array ( 'scheme ' , 'host ' , 'port ' , 'user ' , 'pass ' , 'path ' );
180
- $ valid = true ;
181
- foreach ( $ parts as $ part ) {
182
- if ( isset ( $ registered [ $ part ] ) !== isset ( $ supplied [ $ part ] ) ) {
183
- $ valid = false ;
184
- break ;
185
- }
179
+ foreach ( $ all_registered as $ registered_uri ) {
180
+ $ registered = wp_parse_url ( $ registered_uri );
186
181
187
- if ( ! isset ( $ registered [ $ part ] ) ) {
182
+ // Double-check registered URI is valid.
183
+ if ( ! $ registered ) {
188
184
continue ;
189
185
}
190
186
191
- if ( $ registered [ $ part ] !== $ supplied [ $ part ] ) {
192
- $ valid = false ;
187
+ // Check all components except query and fragment
188
+ $ parts = array ( 'scheme ' , 'host ' , 'port ' , 'user ' , 'pass ' , 'path ' );
189
+ $ valid = true ;
190
+ foreach ( $ parts as $ part ) {
191
+ if ( isset ( $ registered [ $ part ] ) !== isset ( $ supplied [ $ part ] ) ) {
192
+ $ valid = false ;
193
+ break ;
194
+ }
195
+
196
+ if ( ! isset ( $ registered [ $ part ] ) ) {
197
+ continue ;
198
+ }
199
+
200
+ if ( $ registered [ $ part ] !== $ supplied [ $ part ] ) {
201
+ $ valid = false ;
202
+ break ;
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Filter whether a callback is counted as valid.
208
+ *
209
+ * By default, the URLs must match scheme, host, port, user, pass, and
210
+ * path. Query and fragment segments are allowed to be different.
211
+ *
212
+ * To change this behaviour, filter this value. Note that consumers must
213
+ * have a callback registered, even if you relax this restruction. It is
214
+ * highly recommended not to change this behaviour, as clients will
215
+ * expect the same behaviour across all WP sites.
216
+ *
217
+ * @param boolean $valid True if the callback URL is valid, false otherwise.
218
+ * @param string $url Supplied callback URL.
219
+ * @param WP_Post $consumer Consumer post; stored callback saved as `consumer` meta value.
220
+ */
221
+ $ valid = apply_filters ( 'rest_oauth.check_callback ' , $ valid , $ uri , $ this );
222
+ if ( $ valid ) {
223
+ // Stop checking, we have a match.
193
224
break ;
194
225
}
195
226
}
196
227
197
- /**
198
- * Filter whether a callback is counted as valid.
199
- *
200
- * By default, the URLs must match scheme, host, port, user, pass, and
201
- * path. Query and fragment segments are allowed to be different.
202
- *
203
- * To change this behaviour, filter this value. Note that consumers must
204
- * have a callback registered, even if you relax this restruction. It is
205
- * highly recommended not to change this behaviour, as clients will
206
- * expect the same behaviour across all WP sites.
207
- *
208
- * @param boolean $valid True if the callback URL is valid, false otherwise.
209
- * @param string $url Supplied callback URL.
210
- * @param WP_Post $consumer Consumer post; stored callback saved as `consumer` meta value.
211
- */
212
- return apply_filters ( 'rest_oauth.check_callback ' , $ valid , $ uri , $ this );
228
+ return $ valid ;
213
229
}
214
230
215
231
/**
0 commit comments