evaluateTemplateVariable: require property to be a direct/own property of 'values', not from its prototype

This commit is contained in:
Dragory 2019-04-13 04:11:24 +03:00
parent f76dd3ed62
commit 40cb74ee28
3 changed files with 8 additions and 1 deletions

5
package-lock.json generated
View file

@ -5528,6 +5528,11 @@
"resolved": "https://registry.npmjs.org/lodash.difference/-/lodash.difference-4.5.0.tgz",
"integrity": "sha1-nMtOUF1Ia5FlE0V3KIWi3yf9AXw="
},
"lodash.has": {
"version": "4.5.2",
"resolved": "https://registry.npmjs.org/lodash.has/-/lodash.has-4.5.2.tgz",
"integrity": "sha1-0Z9NwQlQWMzL4rDN9O4P5Ko3yGI="
},
"lodash.intersection": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/lodash.intersection/-/lodash.intersection-4.4.0.tgz",

View file

@ -38,6 +38,7 @@
"lodash.at": "^4.6.0",
"lodash.chunk": "^4.2.0",
"lodash.difference": "^4.5.0",
"lodash.has": "^4.5.2",
"lodash.intersection": "^4.4.0",
"lodash.isequal": "^4.5.0",
"moment-timezone": "^0.5.21",

View file

@ -1,3 +1,4 @@
import has from "lodash.has";
import at from "lodash.at";
const TEMPLATE_CACHE_SIZE = 100;
@ -218,7 +219,7 @@ export function parseTemplate(str: string): ParsedTemplate {
}
async function evaluateTemplateVariable(theVar: ITemplateVar, values) {
const value = at(values, theVar.identifier)[0];
const value = has(values, theVar.identifier) && at(values, theVar.identifier)[0];
if (typeof value === "function") {
const args = [];