From 8be96a7ebe1079974f211f227c932409d7c33ef0 Mon Sep 17 00:00:00 2001
From: chimo <chimo@chromic.org>
Date: Sat, 31 May 2014 18:11:04 -0400
Subject: [PATCH] Catches GeoCookie JSON parsing error

---
 js/util.js | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/js/util.js b/js/util.js
index a2b10da8a4..c3ca213f3a 100644
--- a/js/util.js
+++ b/js/util.js
@@ -1177,18 +1177,22 @@ var SN = { // StatusNet
                                 }
                             }
                         } else {
-                            var cookieValue = JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));
-
-                            form.find('[name=lat]').val(cookieValue.NLat);
-                            form.find('[name=lon]').val(cookieValue.NLon);
-                            form.find('[name=location_ns]').val(cookieValue.NLNS);
-                            form.find('[name=location_id]').val(cookieValue.NLID);
-                            form.find('[name=notice_data-geo]').prop('checked', cookieValue.NDG);
-
-                            SN.U.NoticeGeoStatus(form, cookieValue.NLN, cookieValue.NLat, cookieValue.NLon, cookieValue.NLNU);
-                            label
-                                .attr('title', NoticeDataGeo_text.ShareDisable + ' (' + cookieValue.NLN + ')')
-                                .addClass('checked');
+                            try {
+                                var cookieValue = JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));
+
+                                form.find('[name=lat]').val(cookieValue.NLat);
+                                form.find('[name=lon]').val(cookieValue.NLon);
+                                form.find('[name=location_ns]').val(cookieValue.NLNS);
+                                form.find('[name=location_id]').val(cookieValue.NLID);
+                                form.find('[name=notice_data-geo]').prop('checked', cookieValue.NDG);
+
+                               SN.U.NoticeGeoStatus(form, cookieValue.NLN, cookieValue.NLat, cookieValue.NLon, cookieValue.NLNU);
+                                label
+                                    .attr('title', NoticeDataGeo_text.ShareDisable + ' (' + cookieValue.NLN + ')')
+                                    .addClass('checked');
+                            } catch (e) {
+                                console.log('Parsing error:', e);
+                            }
                         }
                     } else {
                         removeNoticeDataGeo();
-- 
2.39.5