[Pkg-javascript-commits] [node-asn1.js] 116/202: node: fix `optional` and `use`
Bastien Roucariès
rouca at moszumanska.debian.org
Thu Apr 20 19:18:59 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 dc0bc4b47446324e50335905aea9a731e509b464
Author: Fedor Indutny <fedor at indutny.com>
Date: Sun Jul 5 19:33:16 2015 -0700
node: fix `optional` and `use`
---
lib/asn1/base/node.js | 36 +++++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)
diff --git a/lib/asn1/base/node.js b/lib/asn1/base/node.js
index 251e4fe..0a6e9e0 100644
--- a/lib/asn1/base/node.js
+++ b/lib/asn1/base/node.js
@@ -271,15 +271,33 @@ Node.prototype._decode = function decode(input) {
// Check if tag is there
if (state.optional) {
- present = this._peekTag(
- input,
- state.explicit !== null ? state.explicit :
- state.implicit !== null ? state.implicit :
- state.tag || 0,
- state.any
- );
- if (input.isError(present))
- return present;
+ var tag = null;
+ if (state.explicit !== null)
+ tag = state.explicit;
+ else if (state.implicit !== null)
+ tag = state.implicit;
+ else if (state.tag !== null)
+ tag = state.tag;
+
+ if (tag === null && !state.any) {
+ // Trial and Error
+ var save = input.save();
+ try {
+ if (state.choice === null)
+ this._decodeGeneric(state.tag, input);
+ else
+ this._decodeChoice(input);
+ present = true;
+ } catch (e) {
+ present = false;
+ }
+ input.restore(save);
+ } else {
+ present = this._peekTag(input, tag, state.any);
+
+ if (input.isError(present))
+ return present;
+ }
}
// Push object on stack
--
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