Skip to content
Snippets Groups Projects
Commit 82c31160 authored by Brian Warner's avatar Brian Warner
Browse files

validate hash-delivered email addresses

This moves the assignment of params.email from the primary-controlled
URL hash (#CREATE_EMAIL= and #ADD_EMAIL=) into the verification block,
and adds bid.verifyEmail() to check them. Closes bug 758449.
parent cd084df2
No related branches found
No related tags found
No related merge requests found
......@@ -167,6 +167,24 @@ BrowserID.Modules.Dialog = (function() {
params.tosURL = fixupURL(origin_url, paramsFromRP.termsOfService);
params.privacyURL = fixupURL(origin_url, paramsFromRP.privacyPolicy);
}
if (hash.indexOf("#CREATE_EMAIL=") === 0) {
var email = hash.replace(/#CREATE_EMAIL=/, "");
if (!bid.verifyEmail(email))
throw "invalid #CREATE_EMAIL= (" + email + ")";
params.type = "primary";
params.email = email;
params.add = false;
}
else if (hash.indexOf("#ADD_EMAIL=") === 0) {
var email = hash.replace(/#ADD_EMAIL=/, "");
if (!bid.verifyEmail(email))
throw "invalid #ADD_EMAIL= (" + email + ")";
params.type = "primary";
params.email = email;
params.add = true;
}
} catch(e) {
// note: renderError accepts HTML and cheerfully injects it into a
// frame with a powerful origin. So convert 'e' first.
......@@ -184,19 +202,6 @@ BrowserID.Modules.Dialog = (function() {
// XXX Perhaps put this into the state machine.
self.bind(win, "unload", onWindowUnload);
if(hash.indexOf("#CREATE_EMAIL=") === 0) {
var email = hash.replace(/#CREATE_EMAIL=/, "");
params.type = "primary";
params.email = email;
params.add = false;
}
else if(hash.indexOf("#ADD_EMAIL=") === 0) {
var email = hash.replace(/#ADD_EMAIL=/, "");
params.type = "primary";
params.email = email;
params.add = true;
}
self.publish("start", params);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment