From a6f7b13d02c20ffad48840832fcff2e23a72a7fb Mon Sep 17 00:00:00 2001 From: atstojanov Date: Sat, 27 Aug 2016 19:41:46 +0300 Subject: crypto: fix getDecoder() encoding check Normalize the encoding in getDecoder() before using it. Fixes an AssertionError: "Cannot change encoding" when encoding is "ucs2", "ucs-2" or "utf-16le" Fixes: https://github.com/nodejs/node/issues/8236 PR-URL: https://github.com/nodejs/node/pull/8301 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- lib/crypto.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/crypto.js') diff --git a/lib/crypto.js b/lib/crypto.js index 9ffff06f7f..16a8524f84 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -100,7 +100,7 @@ Hmac.prototype._transform = Hash.prototype._transform; function getDecoder(decoder, encoding) { - if (encoding === 'utf-8') encoding = 'utf8'; // Normalize encoding. + encoding = internalUtil.normalizeEncoding(encoding); decoder = decoder || new StringDecoder(encoding); assert(decoder.encoding === encoding, 'Cannot change encoding'); return decoder; -- cgit v1.2.3