Chromium Code Reviews

Unified Diff: webkit/glue/devtools/js/inject_dispatch.js

Issue 160098: DevTools: Switch from Value to JSON. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/devtools/js/inject_dispatch.js
===================================================================
--- webkit/glue/devtools/js/inject_dispatch.js (revision 24437)
+++ webkit/glue/devtools/js/inject_dispatch.js (working copy)
@@ -28,10 +28,28 @@
var params = JSON.parse(json_args);
var result = devtools$$obj[functionName].apply(devtools$$obj, params);
return JSON.stringify(result);
-};
+}
/**
+ * Removes malicious functions from the objects so that the pure JSON.stringify
+ * was used.
+ */
+function sanitizeJson(obj) {
+ for (var name in obj) {
+ var property = obj[name];
+ var type = typeof property;
+ if (type === "function") {
+ obj[name] = null;
yurys 2009/08/26 11:51:42 is it safe to do in the 'for in' loop?
+ } else if (type === "object") {
+ sanitizeJson(property);
yurys 2009/08/26 11:51:42 this will fail if property is null because typeof
+ }
+ }
+ return obj;
+}
+
+
+/**
* This is called by the InspectorFrontend for serialization.
* We serialize the call and send it to the client over the IPC
* using dispatchOut bound method.
@@ -48,6 +66,7 @@
// parameters.
return;
}
- var call = JSON.stringify(args);
+
+ var call = JSON.stringify(sanitizeJson(args));
DevToolsAgentHost.dispatch(call);
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine