From f654378f71da13f8ab0a7ec87621ec36f0175552 Mon Sep 17 00:00:00 2001 From: Elastic Jasper Date: Tue, 28 Jun 2016 17:03:05 -0400 Subject: [PATCH] Backport PR #7568 --------- MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Commit 1:** [fix] Fixed scripting issues due to improperly encoded kibana payload. * Original sha: 08a6f401666c96580d3dbb63cb620a6a641176a3 * Authored by Nicolás Bevacqua on 2016-06-28T19:44:18Z **Commit 2:** [fix] Switch to attribute-encoding * Original sha: 2cdb0f9148ad14a0061376e989f1d2343dde93a5 * Authored by Nicolás Bevacqua on 2016-06-28T20:46:50Z **Commit 3:** [fix] Get rid of in favor of directive-style element. * Original sha: e33fa407aeee2c04d65d5b308e355ebda14a22e5 * Authored by Nicolás Bevacqua on 2016-06-28T20:53:25Z --- src/ui/public/metadata.js | 8 +++----- src/ui/views/chrome.jade | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/ui/public/metadata.js b/src/ui/public/metadata.js index 0b3897bb28e16..4f8103221e109 100644 --- a/src/ui/public/metadata.js +++ b/src/ui/public/metadata.js @@ -1,11 +1,9 @@ +import $ from 'jquery'; import _ from 'lodash'; -// singleton for immutable copy of window.__KBN__ -if (!_.has(window, '__KBN__')) { - throw new Error('window.__KBN__ must be set for metadata'); -} +const state = $('kbn-initial-state').attr('data'); +const kbn = window.__KBN__ = JSON.parse(state); -const kbn = _.cloneDeep(window.__KBN__ || {}); export default deepFreeze(kbn); function deepFreeze(object) { diff --git a/src/ui/views/chrome.jade b/src/ui/views/chrome.jade index 646b9bd329a45..45f42d1086a07 100644 --- a/src/ui/views/chrome.jade +++ b/src/ui/views/chrome.jade @@ -1,5 +1,5 @@ -- var j = function (o) { return JSON.stringify(o); } -- var appName = 'kibana'; +- + var appName = 'kibana'; block vars @@ -12,5 +12,5 @@ html(lang='en') title Kibana block head body(kbn-chrome, id='#{appName}-body') - script window.__KBN__ = !{j(kibanaPayload)}; + kbn-initial-state(data=JSON.stringify(kibanaPayload)) block content