Skip to content

Commit b212f45

Browse files
committed
SignedXml - use the right Buffer ctor for digest compares
Do not rely on Buffer.from being a function, as Node 4 does not support encoding with Buffer.from. RegExp the major version instead; if 6 or greater, the ctor is deprecated, and we should use .from
1 parent f9efcfa commit b212f45

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/signed-xml.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,9 @@ SignedXml.prototype.validateReferences = function(doc) {
494494
function validateDigestValue(digest, expectedDigest) {
495495
var buffer, expectedBuffer;
496496

497-
if (typeof Buffer.from === 'function') {
497+
var majorVersion = /^v(\d+)/.exec(process.version)[1];
498+
499+
if (+majorVersion >= 6) {
498500
buffer = Buffer.from(digest, 'base64');
499501
expectedBuffer = Buffer.from(expectedDigest, 'base64');
500502
} else {

0 commit comments

Comments
 (0)