From 70a22ad5ff6e5f79fe8c65bee7f072ad5b354583 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 4 Jan 2017 16:15:09 +0000 Subject: [PATCH] encode initial state json for more secure and reliable inclusion in rendered page --- src/client/index.js | 4 ++-- src/server/render.js | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/client/index.js b/src/client/index.js index da753cd..bcd848b 100644 --- a/src/client/index.js +++ b/src/client/index.js @@ -19,7 +19,7 @@ import LocalStorage from './LocalStorage' //initial state is rehydrated from the server -const initialState = window.__INITIAL_STATE__ +const initialState = JSON.parse(decodeURI(window.__INITIAL_STATE__)) //create the redux store //initial state is retrieved from localStore @@ -47,4 +47,4 @@ function render() { } render() - \ No newline at end of file + diff --git a/src/server/render.js b/src/server/render.js index 760a879..3be1ab9 100644 --- a/src/server/render.js +++ b/src/server/render.js @@ -54,7 +54,6 @@ const pageTemplate = (body) => { - ${body} @@ -81,7 +80,7 @@ function appTemplate(html, initialState) {
${html}