Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2026 from mozilla-services/compat-fix
Browse files Browse the repository at this point in the history
r?fzzzy Be resilient when receiving bad deviceInfo (as older versions of the …
  • Loading branch information
fzzzy authored Nov 30, 2016
2 parents ad6e409 + 03e2b17 commit 0f87fff
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion server/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,17 @@ app.post("/api/update", function (req, res, next) {

app.post("/api/login", function (req, res) {
let vars = req.body;
let deviceInfo = JSON.parse(vars.deviceInfo);
let deviceInfo = {};
try {
deviceInfo = JSON.parse(vars.deviceInfo);
} catch (e) {
if (e instanceof SyntaxError) {
// JSON isn't valid
deviceInfo = {};
} else {
throw e;
}
}
checkLogin(vars.deviceId, vars.secret, deviceInfo.addonVersion).then((ok) => {
if (ok) {
let cookies = new Cookies(req, res, {keys: dbschema.getKeygrip()});
Expand Down

0 comments on commit 0f87fff

Please sign in to comment.