From d542fa52527ca42d56c2934bebbbe1587f619809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D0=B2=D0=BE=D1=80=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=90=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2=D0=B8=D1=87?= Date: Wed, 14 Mar 2018 03:15:55 +0300 Subject: [PATCH] Use safe-buffer for improved Buffer API closes #21 --- HISTORY.md | 5 +++++ index.js | 3 ++- package.json | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 53849b6..2ecd55a 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +unreleased +========== + + * Use `safe-buffer` for improved Buffer API + 0.5.2 / 2016-12-08 ================== diff --git a/index.js b/index.js index 57d8ee4..2474d05 100644 --- a/index.js +++ b/index.js @@ -20,6 +20,7 @@ module.exports.parse = parse */ var basename = require('path').basename +var Buffer = require('safe-buffer').Buffer /** * RegExp to match non attr-char, *after* encodeURIComponent (i.e. not including "%") @@ -280,7 +281,7 @@ function decodefield (str) { value = getlatin1(binary) break case 'utf-8': - value = new Buffer(binary, 'binary').toString('utf8') + value = Buffer.from(binary, 'binary').toString('utf8') break default: throw new TypeError('unsupported charset in extended field') diff --git a/package.json b/package.json index 32797ff..11cd22f 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,9 @@ "res" ], "repository": "jshttp/content-disposition", + "dependencies": { + "safe-buffer": "5.1.1" + }, "devDependencies": { "eslint": "3.19.0", "eslint-config-standard": "7.0.0",