Opened 3 days ago
Last modified 42 hours ago
#49404 new defect (bug)
WP_REST_Request->parse_json_params only supports 'application/json'
| Reported by: |  | Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal | 
| Severity: | normal | Version: | |
| Component: | REST API | Keywords: | |
| Focuses: | rest-api | Cc: | |
| PR Number: | 
Description
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.
Change History (3)
    
      
         
        
This ticket was mentioned in Slack in #core-restapi by pfefferle. View the logs.
      
      
3 days ago
    
    
  
              
    
      
         
        
This ticket was mentioned in Slack in #core by noisysocks. View the logs.
      
      
42 hours ago
    
    
  
              Note: See
        TracTickets for help on using
        tickets.
    
 
                       
                
                       
			     
			 
                
JSON Content-(Sub)Type examples:
ActivityPub https://www.w3.org/TR/activitypub/
JF2Feed https://www.w3.org/TR/jf2/
JSON Web Signature (JWS) https://tools.ietf.org/html/rfc7515
WebFinger https://tools.ietf.org/html/rfc7033
Here is the complete list: https://www.iana.org/assignments/media-types/media-types.xhtml#application