[Pkg-javascript-commits] [node-asn1.js] 101/202: node: fix optional+any

Bastien Roucariès rouca at moszumanska.debian.org
Thu Apr 20 19:18:58 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 895797725e73d693a301f4c39e6551cf17491981
Author: Fedor Indutny <fedor at indutny.com>
Date:   Tue May 19 23:58:32 2015 +0200

    node: fix optional+any
    
    Fix: #40
---
 lib/asn1/base/node.js       | 2 +-
 rfc/3280/test/basic-test.js | 1 +
 test/ping-pong-test.js      | 6 ++++++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/asn1/base/node.js b/lib/asn1/base/node.js
index 9c03beb..8427439 100644
--- a/lib/asn1/base/node.js
+++ b/lib/asn1/base/node.js
@@ -271,7 +271,7 @@ Node.prototype._decode = function decode(input) {
 
   // Check if tag is there
   if (state.optional) {
-    present = this._peekTag(
+    present = state.any || this._peekTag(
       input,
       state.explicit !== null ? state.explicit :
           state.implicit !== null ? state.implicit :
diff --git a/rfc/3280/test/basic-test.js b/rfc/3280/test/basic-test.js
index 128ddbb..2250128 100644
--- a/rfc/3280/test/basic-test.js
+++ b/rfc/3280/test/basic-test.js
@@ -50,5 +50,6 @@ describe('asn1.js RFC3280', function() {
                      new asn1.bignum('462e4256bb1194dc', 16));
     assert.equal(tbs.signature.algorithm.join('.'),
                  '1.2.840.113549.1.1.5');
+    assert.equal(tbs.signature.parameters.toString('hex'), '0500');
   });
 });
diff --git a/test/ping-pong-test.js b/test/ping-pong-test.js
index 10557b8..40be7ac 100644
--- a/test/ping-pong-test.js
+++ b/test/ping-pong-test.js
@@ -129,6 +129,12 @@ describe('asn1.js ping/pong', function() {
       );
     }, {}, {});
 
+    test('optional + any', function() {
+      this.seq().obj(
+        this.key('content').optional().any()
+      );
+    }, { content: new Buffer('0500', 'hex') });
+
     test('seqof', function() {
       var S = asn1.define('S', function() {
         this.seq().obj(

-- 
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