diff options
author | atstojanov <atstojanov@gmail.com> | 2016-08-27 19:41:46 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2016-09-04 18:39:43 +0200 |
commit | a6f7b13d02c20ffad48840832fcff2e23a72a7fb (patch) | |
tree | b547ff27123e676fa436ab077a24e280f5ecaf45 /lib/crypto.js | |
parent | 983775d457a8022c271488a9eaac56caf8944aed (diff) | |
download | android-node-v8-a6f7b13d02c20ffad48840832fcff2e23a72a7fb.tar.gz android-node-v8-a6f7b13d02c20ffad48840832fcff2e23a72a7fb.tar.bz2 android-node-v8-a6f7b13d02c20ffad48840832fcff2e23a72a7fb.zip |
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 <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/crypto.js')
-rw-r--r-- | lib/crypto.js | 2 |
1 files changed, 1 insertions, 1 deletions
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; |