Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

escapes script #1356

Merged
merged 1 commit into from
Mar 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/core/src/server.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ const baseTag = process.env.CANON_BASE_URL === undefined ? ""
/**
Returns the default server logic for rendering a page.
*/
export default function (defaultStore = appInitialState, headerConfig, reduxMiddleware = false) {
export default function(defaultStore = appInitialState, headerConfig, reduxMiddleware = false) {

return function (req, res) {
return function(req, res) {

const locale = req.i18n.language,
resources = req.i18n.getResourceBundle(req.i18n.language);
resources = req.i18n.getResourceBundle(req.i18n.language);

const windowLocation = {
basename,
Expand Down Expand Up @@ -120,8 +120,8 @@ export default function (defaultStore = appInitialState, headerConfig, reduxMidd
const helmetContext = {};

let componentHTML,
scriptTags = "<script type=\"text/javascript\" charset=\"utf-8\" src=\"/assets/client.js\"></script>",
styleTags = "<link rel=\"stylesheet\" type=\"text/css\" href=\"/assets/styles.css\">";
scriptTags = "<script type=\"text/javascript\" charset=\"utf-8\" src=\"/assets/client.js\"></script>",
styleTags = "<link rel=\"stylesheet\" type=\"text/css\" href=\"/assets/styles.css\">";

if (production) {

Expand Down Expand Up @@ -195,7 +195,7 @@ export default function (defaultStore = appInitialState, headerConfig, reduxMidd
styleTags = styleTags.replace(/\/assets\//g, "assets/");
}

const serialize = obj => `JSON.parse('${jsesc(JSON.stringify(obj))}')`;
const serialize = obj => `JSON.parse('${jsesc(JSON.stringify(obj), {isScriptContext: true})}')`;

return res.status(status).send(`<!doctype html>
<html dir="${rtl ? "rtl" : "ltr"}" ${htmlAttrs}${defaultAttrs}>
Expand Down