Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Target Hints: Add missing param sanitization #65280

Merged
merged 5 commits into from
Sep 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions lib/compat/wordpress-6.7/class-gutenberg-rest-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,22 @@ public static function get_response_links( $response ) {
continue;
}

$match = $server->match_request_to_handler( $request );
if ( ! is_wp_error( $match ) ) {
$response = new WP_REST_Response();
$response->set_matched_route( $match[0] );
$response->set_matched_handler( $match[1] );
$headers = rest_send_allow_header( $response, $server, $request )->get_headers();

foreach ( $headers as $name => $value ) {
$name = WP_REST_Request::canonicalize_header_name( $name );
$attributes['targetHints'][ $name ] = array_map( 'trim', explode( ',', $value ) );
$matched = $server->match_request_to_handler( $request );
if ( ! is_wp_error( $matched ) ) {
if ( ! is_wp_error( $request->has_valid_params() ) ) {
if ( ! is_wp_error( $request->sanitize_params() ) ) {
swissspidy marked this conversation as resolved.
Show resolved Hide resolved
list( $route, $handler ) = $matched;

$response = new WP_REST_Response();
$response->set_matched_route( $route );
$response->set_matched_handler( $handler );
$headers = rest_send_allow_header( $response, $server, $request )->get_headers();

foreach ( $headers as $name => $value ) {
$name = WP_REST_Request::canonicalize_header_name( $name );
$attributes['targetHints'][ $name ] = array_map( 'trim', explode( ',', $value ) );
}
}
}
}

Expand Down
Loading