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

Unified Diff: mojo/public/js/bindings/router.js

Issue 424463003: Basic Mojo message header validation for JavaScript. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make claimRange() consistent with isValidRange() Created 6 years, 5 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
« no previous file with comments | « mojo/public/js/bindings/constants.cc ('k') | mojo/public/js/bindings/validator.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/js/bindings/router.js
diff --git a/mojo/public/js/bindings/router.js b/mojo/public/js/bindings/router.js
index 2718e8b0b7805bec9a81350cadd95a6b8fb13d3f..a00fc0a05a0e7ddb041d69d71fc3fe65edd05f3c 100644
--- a/mojo/public/js/bindings/router.js
+++ b/mojo/public/js/bindings/router.js
@@ -5,7 +5,8 @@
define("mojo/public/js/bindings/router", [
"mojo/public/js/bindings/codec",
"mojo/public/js/bindings/connector",
-], function(codec, connector) {
+ "mojo/public/js/bindings/validator",
+], function(codec, connector, validator) {
function Router(handle) {
this.connector_ = new connector.Connector(handle);
@@ -60,8 +61,11 @@ define("mojo/public/js/bindings/router", [
};
Router.prototype.handleIncomingMessage_ = function(message) {
- var flags = message.getFlags();
- if (flags & codec.kMessageExpectsResponse) {
+ var v = new validator.Validator(message);
+ if (v.validateMessage() !== validator.validationError.NONE)
+ this.close();
+
+ if (message.expectsResponse()) {
if (this.incomingReceiver_) {
this.incomingReceiver_.acceptWithResponder(message, this);
} else {
@@ -69,7 +73,7 @@ define("mojo/public/js/bindings/router", [
// listening, then we have no choice but to tear down the pipe.
this.close();
}
- } else if (flags & codec.kMessageIsResponse) {
+ } else if (message.isResponse()) {
var reader = new codec.MessageReader(message);
var requestID = reader.requestID;
var responder = this.responders_[requestID];
« no previous file with comments | « mojo/public/js/bindings/constants.cc ('k') | mojo/public/js/bindings/validator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698