From 6d9f937d87814b069bc6f13408fcf18cee954ffc Mon Sep 17 00:00:00 2001 From: Chris Cowan Date: Mon, 8 Dec 2014 14:35:40 -0700 Subject: [PATCH 1/2] Closes #2103 - Handling Rison exception for malformated urls --- src/kibana/components/state_management/state.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/kibana/components/state_management/state.js b/src/kibana/components/state_management/state.js index 228f9bc047abe..6f3bd1b956edb 100644 --- a/src/kibana/components/state_management/state.js +++ b/src/kibana/components/state_management/state.js @@ -5,7 +5,7 @@ define(function (require) { var applyDiff = require('utils/diff_object'); var qs = require('utils/query_string'); - return function StateProvider(Private, $rootScope, $location) { + return function StateProvider(Notifier, Private, $rootScope, $location) { var Events = Private(require('factories/events')); _(State).inherits(Events); @@ -40,7 +40,13 @@ define(function (require) { State.prototype._readFromURL = function () { var search = $location.search(); - return search[this._urlParam] ? rison.decode(search[this._urlParam]) : null; + try { + return search[this._urlParam] ? rison.decode(search[this._urlParam]) : null; + } catch (e) { + var notify = new Notifier(); + notify.error('Unable to parse URL'); + return null; + } }; /** From e0537fce6efaed8ee5ae4d35a63a1da94784108d Mon Sep 17 00:00:00 2001 From: Chris Cowan Date: Mon, 8 Dec 2014 16:51:38 -0700 Subject: [PATCH 2/2] If we get an error then we will clean it up and replace it with the defautls --- src/kibana/components/state_management/state.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/kibana/components/state_management/state.js b/src/kibana/components/state_management/state.js index 6f3bd1b956edb..f5d9f172f5210 100644 --- a/src/kibana/components/state_management/state.js +++ b/src/kibana/components/state_management/state.js @@ -45,6 +45,8 @@ define(function (require) { } catch (e) { var notify = new Notifier(); notify.error('Unable to parse URL'); + search[this._urlParam] = rison.encode(this._defaults); + $location.search(search).replace(); return null; } };