diff options
author | Fedor Indutny <fedor.indutny@gmail.com> | 2014-03-10 14:59:18 +0400 |
---|---|---|
committer | Fedor Indutny <fedor.indutny@gmail.com> | 2014-03-11 01:08:43 +0400 |
commit | f0d870501ed240f550b2be6b0a138312fb6f4a30 (patch) | |
tree | 264b9746f1a3bce666402e0f370a24ed08d26c78 /lib | |
parent | 6bd78fd7704a8a695fc76430b573bc482f42c320 (diff) | |
download | android-node-v8-f0d870501ed240f550b2be6b0a138312fb6f4a30.tar.gz android-node-v8-f0d870501ed240f550b2be6b0a138312fb6f4a30.tar.bz2 android-node-v8-f0d870501ed240f550b2be6b0a138312fb6f4a30.zip |
crypto: do not lowercase cipher/hash names
`crypto.getCiphers()` and `crypto.getHashes()` should prefer lower-case
variants of names, but should not introduce them.
fix #7282
Diffstat (limited to 'lib')
-rw-r--r-- | lib/crypto.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/crypto.js b/lib/crypto.js index 22141ff8ae..d1c9eb5d2e 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -608,8 +608,13 @@ function filterDuplicates(names) { // for example, 'sha1' instead of 'SHA1'. var ctx = {}; names.forEach(function(name) { - if (/^[0-9A-Z\-]+$/.test(name)) name = name.toLowerCase(); - ctx[name] = true; + var key = name; + if (/^[0-9A-Z\-]+$/.test(key)) key = key.toLowerCase(); + if (!ctx.hasOwnProperty(key) || ctx[key] < name) + ctx[key] = name; }); - return Object.getOwnPropertyNames(ctx).sort(); + + return Object.getOwnPropertyNames(ctx).map(function(key) { + return ctx[key]; + }).sort(); } |