Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(609)

Unified Diff: Source/core/inspector/InjectedScriptSource.js

Issue 470543002: DevTools: Don't allow native global functions in injected script. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/inspector/InjectedScriptSource.js
diff --git a/Source/core/inspector/InjectedScriptSource.js b/Source/core/inspector/InjectedScriptSource.js
index 3c29246275f8626dd02ba6139c366c60b4313bcd..c85c7eb32db25df2bc6bae052cadffebe33f7159 100644
--- a/Source/core/inspector/InjectedScriptSource.js
+++ b/Source/core/inspector/InjectedScriptSource.js
@@ -140,6 +140,15 @@ function nullifyObjectProto(obj)
}
/**
+ * @param {*} obj
+ * @return {boolean}
+ */
+function isUInt32(obj)
+{
+ return typeof obj === "number" && obj >>> 0 === obj && (obj > 0 || 1 / obj > 0);
+}
+
+/**
* FireBug's array detection.
* @param {*} obj
* @return {boolean}
@@ -150,10 +159,10 @@ function isArrayLike(obj)
if (typeof obj !== "object")
return false;
if (typeof obj.splice === "function")
- return isFinite(obj.length);
+ return isUInt32(obj.length);
var str = InjectedScriptHost.callFunction(Object.prototype.toString, obj);
if (str === "[object Arguments]")
- return isFinite(obj.length);
+ return isUInt32(obj.length);
} catch (e) {
}
return false;

Powered by Google App Engine
This is Rietveld 408576698