[wp-trac] [WordPress Trac] #49404: WP_REST_Request->parse_json_params only supports 'application/json'

WordPress Trac noreply at wordpress.org
Tue Feb 11 14:07:26 UTC 2020


#49404: WP_REST_Request->parse_json_params only supports 'application/json'
--------------------------+-----------------------------
 Reporter:  pfefferle     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  REST API      |    Version:
 Severity:  normal        |   Keywords:
  Focuses:  rest-api      |
--------------------------+-----------------------------
 The `parse_json_params` function only supports `application/json` to parse
 the body as JSON, that means every subtype like `application/ld+json` or
 `application/activity+json` will be ignored. It is also possible to add
 additional data like `application/json;
 profile="https://www.w3.org/ns/activitystreams"` that will be also ignored
 by the current implementation.

 I would recomment to use a more generic check like:

 `preg_match( '/application\/(\w+\+)?json.*/i', $content_type )`

 and/or a filter to overwrite the check.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49404>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list