-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(common): fix XSSI prefix stripping by using JSON.parse always (#1…
…8466) Currently HttpClient sends requests for JSON data with the XMLHttpRequest.responseType set to 'json'. With this flag, the browser will attempt to parse the response as JSON, but will return 'null' on any errors. If the JSON response contains an XSSI-prevention prefix, this will cause the browser's parsing to fail, which is unrecoverable. The only compelling reason to use the responseType 'json' is for performance (especially if the browser offloads JSON parsing to a separate thread). I'm not aware of any browser which does this currently, nor of any plans to do so. JSON.parse and responseType 'json' both end up using the same V8 code path in Chrome to implement the parse. Thus, this change switches all JSON parsing in HttpClient to use JSON.parse directly. Fixes #18396, #18453. PR Close #18466
- Loading branch information
Showing
3 changed files
with
25 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You could remove the comment
(in many cases the browser will have done that already)
as you disabled that behavior altogether.