From 19c5bb03eade5d19e4c24882cd2a43ba7bc5b631 Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Wed, 19 Aug 2020 20:04:36 -0700 Subject: [PATCH] Fix exception when passing null as PARAM arg --- lib/api-functions.ts | 2 +- lib/common/expression.ts | 2 ++ lib/session.ts | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/api-functions.ts b/lib/api-functions.ts index e7950f8..f6ef813 100644 --- a/lib/api-functions.ts +++ b/lib/api-functions.ts @@ -84,7 +84,7 @@ export async function connectionRequest( const evalCallback = (exp): Expression => { if (!Array.isArray(exp)) return exp; - if (exp[0] === "PARAM") { + if (exp[0] === "PARAM" && typeof exp[1] === "string") { let name = exp[1]; if (name === "id") name = "DeviceID.ID"; else if (name === "serialNumber") name = "DeviceID.SerialNumber"; diff --git a/lib/common/expression.ts b/lib/common/expression.ts index 593c1d6..14ae401 100644 --- a/lib/common/expression.ts +++ b/lib/common/expression.ts @@ -131,6 +131,8 @@ export function evaluateCallback(exp: Expression): Expression { if (exp[2] == null) return null; if (!isArray(exp[2])) return toString(exp[2]).toLowerCase(); } + } else if (exp[0] === "PARAM") { + if (exp[1] == null) return null; } else if (exp[0] === "AND") { for (let i = 1; i < exp.length; ++i) if (!Array.isArray(exp[i]) && exp[i] != null && !exp[i]) return false; diff --git a/lib/session.ts b/lib/session.ts index 79881b5..948dfb7 100644 --- a/lib/session.ts +++ b/lib/session.ts @@ -113,7 +113,7 @@ export function configContextCallback( exp: Expression ): Expression { if (!Array.isArray(exp)) return exp; - if (exp[0] === "PARAM") { + if (exp[0] === "PARAM" && typeof exp[1] === "string") { let name = exp[1]; if (name === "id") name = "DeviceID.ID"; else if (name === "serialNumber") name = "DeviceID.SerialNumber";