Skip to content

Commit 6ee7ee9

Browse files
committed
fix: xss issue
closes #145
1 parent 5afd5d5 commit 6ee7ee9

3 files changed

Lines changed: 41 additions & 14 deletions

File tree

package-lock.json

Lines changed: 37 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"@types/react-dom": "^16.8.2",
8282
"@types/react-helmet": "^5.0.8",
8383
"@types/react-redux": "^7.0.1",
84+
"@types/serialize-javascript": "^1.5.0",
8485
"awesome-typescript-loader": "^5.2.1",
8586
"babel-core": "^6.26.3",
8687
"cross-env": "^5.2.0",
@@ -130,6 +131,7 @@
130131
"redux-saga": "^1.0.1",
131132
"reselect": "^4.0.0",
132133
"router5": "^6.6.3",
134+
"serialize-javascript": "^1.6.1",
133135
"serve-favicon": "^2.5.0",
134136
"typesafe-actions": "^3.1.0",
135137
"typestyle": "^2.0.1"

src/app/containers/Html.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import autobind from "autobind-decorator";
22
import * as React from "react";
33
import {Helmet} from "react-helmet";
4+
import * as serialize from "serialize-javascript";
45
import {getStyles} from "typestyle";
56
import {IStore} from "../redux/IStore";
67

@@ -23,7 +24,7 @@ export class Html extends React.Component<IHtmlProps> {
2324

2425
const initialStateScript = (
2526
<script
26-
dangerouslySetInnerHTML={{__html: `window.__INITIAL_STATE__=${JSON.stringify(initialState)};`}}
27+
dangerouslySetInnerHTML={{__html: `window.__INITIAL_STATE__=${serialize(initialState, {isJSON: true})};`}}
2728
charSet="UTF-8"
2829
/>
2930
);

0 commit comments

Comments
 (0)