mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge pull request #4519 from node-red/4479-ensure-env-not-modified
Clone objects types when getting env values
This commit is contained in:
commit
1bef0c32a2
@ -485,7 +485,7 @@ class Flow {
|
|||||||
}
|
}
|
||||||
if (!key.startsWith("$parent.")) {
|
if (!key.startsWith("$parent.")) {
|
||||||
if (this._env.hasOwnProperty(key)) {
|
if (this._env.hasOwnProperty(key)) {
|
||||||
return this._env[key]
|
return (Object.hasOwn(this._env[key], 'value') && this._env[key].__clone__) ? clone(this._env[key].value) : this._env[key]
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
key = key.substring(8);
|
key = key.substring(8);
|
||||||
|
@ -41,7 +41,7 @@ class Group {
|
|||||||
}
|
}
|
||||||
if (!key.startsWith("$parent.")) {
|
if (!key.startsWith("$parent.")) {
|
||||||
if (this._env.hasOwnProperty(key)) {
|
if (this._env.hasOwnProperty(key)) {
|
||||||
return this._env[key]
|
return (Object.hasOwn(this._env[key], 'value') && this._env[key].__clone__) ? clone(this._env[key].value) : this._env[key]
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
key = key.substring(8);
|
key = key.substring(8);
|
||||||
|
@ -375,7 +375,7 @@ class Subflow extends Flow {
|
|||||||
}
|
}
|
||||||
if (!key.startsWith("$parent.")) {
|
if (!key.startsWith("$parent.")) {
|
||||||
if (this._env.hasOwnProperty(key)) {
|
if (this._env.hasOwnProperty(key)) {
|
||||||
return this._env[key]
|
return (Object.hasOwn(this._env[key], 'value') && this._env[key].__clone__) ? clone(this._env[key].value) : this._env[key]
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
key = key.substring(8);
|
key = key.substring(8);
|
||||||
|
@ -102,6 +102,9 @@ async function evaluateEnvProperties(flow, env, credentials) {
|
|||||||
pendingEvaluations.push(new Promise((resolve, _) => {
|
pendingEvaluations.push(new Promise((resolve, _) => {
|
||||||
redUtil.evaluateNodeProperty(value, 'jsonata', {_flow: flow}, null, (err, result) => {
|
redUtil.evaluateNodeProperty(value, 'jsonata', {_flow: flow}, null, (err, result) => {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
|
if (typeof result === 'object') {
|
||||||
|
result = { value: result, __clone__: true}
|
||||||
|
}
|
||||||
evaluatedEnv[name] = result
|
evaluatedEnv[name] = result
|
||||||
}
|
}
|
||||||
resolve()
|
resolve()
|
||||||
@ -109,6 +112,9 @@ async function evaluateEnvProperties(flow, env, credentials) {
|
|||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
value = redUtil.evaluateNodeProperty(value, type, {_flow: flow}, null, null);
|
value = redUtil.evaluateNodeProperty(value, type, {_flow: flow}, null, null);
|
||||||
|
if (typeof value === 'object') {
|
||||||
|
value = { value: value, __clone__: true}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
evaluatedEnv[name] = value
|
evaluatedEnv[name] = value
|
||||||
}
|
}
|
||||||
@ -138,8 +144,13 @@ async function evaluateEnvProperties(flow, env, credentials) {
|
|||||||
}
|
}
|
||||||
}}, null, null);
|
}}, null, null);
|
||||||
}
|
}
|
||||||
|
if (typeof value === 'object' && !value.__clone__) {
|
||||||
|
value = { value: value, __clone__: true}
|
||||||
|
}
|
||||||
evaluatedEnv[name] = value
|
evaluatedEnv[name] = value
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// console.log(evaluatedEnv)
|
||||||
|
|
||||||
return evaluatedEnv
|
return evaluatedEnv
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user