Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save polymorphm/1200224 to your computer and use it in GitHub Desktop.
Save polymorphm/1200224 to your computer and use it in GitHub Desktop.
From d9c8edec62506ab83cde0c0285445ad8c375f709 Mon Sep 17 00:00:00 2001
From: Andrej A Antonov <[email protected]>
Date: Wed, 7 Sep 2011 14:07:51 +0400
Subject: [PATCH] browserid/static/include.js: if message is not in JSON-string format
---
browserid/static/include.js | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/browserid/static/include.js b/browserid/static/include.js
index 5d07605..cdf1f65 100644
--- a/browserid/static/include.js
+++ b/browserid/static/include.js
@@ -111,7 +111,13 @@ if (!navigator.id.getVerifiedEmail || navigator.id._getVerifiedEmailIsShimmed)
// arrangement allows certain efficiencies, message data is only parsed once and dispatch
// is more efficient, especially for large numbers of simultaneous channels.
var s_onMessage = function(e) {
- var m = JSON.parse(e.data);
+ var m;
+ try {
+ m = JSON.parse(e.data);
+ } catch(er) {
+ // message-format is not JSON-string
+ return;
+ }
if (typeof m !== 'object') return;
var o = e.origin;
--
1.7.4.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment