Visitar URL original
fix: use strict UTF-8 decoding in json() to reject invalid bytes by kshyatisekhar-panda · Pull Request #1879 · node-fetch/node-fetch · GitHub
Skip to content
Open
Changes from all commits
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
3 changes: 2 additions & 1 deletion src/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ export default class Body {
* @return Promise
*/
async json() {
const text = await this.text();
const buffer = await consumeBody(this);
const text = new TextDecoder('utf-8', {fatal: true}).decode(buffer);
return JSON.parse(text);
}

Expand Down