[Pkg-javascript-commits] [node-asn1.js] 139/202: der: support `dot` values in decoder

Bastien Roucariès rouca at moszumanska.debian.org
Thu Apr 20 19:19:02 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-asn1.js.

commit 7f8a964d33a309896d6d6ef9cdf834ab7f731ad6
Author: Fedor Indutny <fedor at indutny.com>
Date:   Tue Jan 5 14:33:01 2016 -0500

    der: support `dot` values in decoder
---
 lib/asn1/decoders/der.js | 10 +++++++---
 test/der-decode-test.js  |  6 ++++++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/lib/asn1/decoders/der.js b/lib/asn1/decoders/der.js
index 6b0ed18..4c32d0b 100644
--- a/lib/asn1/decoders/der.js
+++ b/lib/asn1/decoders/der.js
@@ -165,7 +165,6 @@ DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
 };
 
 DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) {
-  var result;
   var identifiers = [];
   var ident = 0;
   while (!buffer.isEmpty()) {
@@ -188,8 +187,13 @@ DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative)
   else
     result = [first, second].concat(identifiers.slice(1));
 
-  if (values)
-    result = values[result.join(' ')];
+  if (values) {
+    var tmp = values[result.join(' ')];
+    if (tmp === undefined)
+      tmp = values[result.join('.')];
+    if (tmp !== undefined)
+      result = tmp;
+  }
 
   return result;
 };
diff --git a/test/der-decode-test.js b/test/der-decode-test.js
index 277ad36..d976ac4 100644
--- a/test/der-decode-test.js
+++ b/test/der-decode-test.js
@@ -84,4 +84,10 @@ describe('asn1.js DER decoder', function() {
   test('should decode bmpstr with cyrillic chars', function() {
     this.bmpstr();
   }, '1e0c041f04400438043204350442', 'Привет');
+
+  test('should properly decode objid with dots', function() {
+    this.objid({
+      '1.2.398.3.10.1.1.1.2.2': 'yes'
+    });
+  }, '060a2a830e030a0101010202', 'yes');
 });

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-asn1.js.git



More information about the Pkg-javascript-commits mailing list