From d9f6232a8168f11561c777d2607d34b5560355ad Mon Sep 17 00:00:00 2001 From: Austin Peterson Date: Mon, 13 Feb 2017 17:21:10 -0500 Subject: [PATCH 1/3] common: add hasOwnProperty to for...in loop. Fixes #1984. This is to stop the for...in loop from looping over properties that aren't actually part of the object, which can lead to the call stack overflowing under certain circumstances. --- packages/common/src/util.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/common/src/util.js b/packages/common/src/util.js index cd4afe02b9f..bfaddf3af65 100644 --- a/packages/common/src/util.js +++ b/packages/common/src/util.js @@ -518,7 +518,9 @@ function replaceProjectIdToken(value, projectId) { if (is.object(value)) { for (var opt in value) { - value[opt] = replaceProjectIdToken(value[opt], projectId); + if(value.hasOwnProperty(value)) { + value[opt] = replaceProjectIdToken(value[opt], projectId); + } } } From 3293b6724c2a37132358fe804ecf46a70dd913e4 Mon Sep 17 00:00:00 2001 From: Stephen Sawchuk Date: Tue, 14 Feb 2017 10:18:50 -0500 Subject: [PATCH 2/3] Update util.js --- packages/common/src/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/common/src/util.js b/packages/common/src/util.js index bfaddf3af65..a01e5553659 100644 --- a/packages/common/src/util.js +++ b/packages/common/src/util.js @@ -518,7 +518,7 @@ function replaceProjectIdToken(value, projectId) { if (is.object(value)) { for (var opt in value) { - if(value.hasOwnProperty(value)) { + if (value.hasOwnProperty(value)) { value[opt] = replaceProjectIdToken(value[opt], projectId); } } From 98e0590e3ecc5957a011137cc56a86e389102acf Mon Sep 17 00:00:00 2001 From: Austin Peterson Date: Tue, 14 Feb 2017 10:24:43 -0500 Subject: [PATCH 3/3] Fix typo in hasOwnProperty. --- packages/common/src/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/common/src/util.js b/packages/common/src/util.js index a01e5553659..2411e80c69e 100644 --- a/packages/common/src/util.js +++ b/packages/common/src/util.js @@ -518,7 +518,7 @@ function replaceProjectIdToken(value, projectId) { if (is.object(value)) { for (var opt in value) { - if (value.hasOwnProperty(value)) { + if (value.hasOwnProperty(opt)) { value[opt] = replaceProjectIdToken(value[opt], projectId); } }