From c6e3f93ebb716c2df310e4ca4fd1f4c8290feed1 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Fri, 13 Aug 2021 23:04:24 +0530 Subject: fix(ext/crypto): handle idlValue not being present (#11685) --- ext/crypto/00_crypto.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'ext') diff --git a/ext/crypto/00_crypto.js b/ext/crypto/00_crypto.js index 4319f09ba..b341aabe7 100644 --- a/ext/crypto/00_crypto.js +++ b/ext/crypto/00_crypto.js @@ -88,6 +88,7 @@ }; // See https://www.w3.org/TR/WebCryptoAPI/#dfn-normalize-an-algorithm + // 18.4.4 function normalizeAlgorithm(algorithm, op) { if (typeof algorithm == "string") { return normalizeAlgorithm({ name: algorithm }, op); @@ -125,18 +126,22 @@ return { name: algName }; } + // 6. const normalizedAlgorithm = webidl.converters[desiredType](algorithm, { prefix: "Failed to normalize algorithm", context: "passed algorithm", }); + // 7. normalizedAlgorithm.name = algName; + // 9. const dict = simpleAlgorithmDictionaries[desiredType]; + // 10. for (const member in dict) { const idlType = dict[member]; const idlValue = normalizedAlgorithm[member]; - - if (idlType === "BufferSource") { + // 3. + if (idlType === "BufferSource" && idlValue) { normalizedAlgorithm[member] = new Uint8Array( TypedArrayPrototypeSlice( (ArrayBufferIsView(idlValue) ? idlValue.buffer : idlValue), -- cgit v1.2.3