Skip to content

Commit

Permalink
handle undefined in shoebox
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelly Selden committed May 16, 2017
1 parent acbb306 commit 5fafef8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ember-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,9 @@ function createShoebox(doc, fastbootInfo) {

let value = shoebox[key];
let textValue = JSON.stringify(value);
textValue = escapeJSONString(textValue);
if (textValue !== undefined) {
textValue = escapeJSONString(textValue);
}

let scriptText = doc.createRawHTMLSection(textValue);
let scriptEl = doc.createElement('script');
Expand Down
9 changes: 9 additions & 0 deletions test/fastboot-shoebox-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ describe("FastBootShoebox", function() {
expect(html).to.include('<script type="fastboot/shoebox" id="shoebox-key4">{"nastyScriptCase":"\\u003cscript\\u003ealert(\'owned\');\\u003c/script\\u003e\\u003c/script\\u003e\\u003c/script\\u003e"}</script>');

expect(html).to.include('<script type="fastboot/shoebox" id="shoebox-key5">{"otherUnicodeChars":"\\u0026\\u0026\\u003e\\u003e\\u003c\\u003c\\u2028\\u2028\\u2029\\u2029"}</script>');

// handles undefined
expect(html).to.include('<script type="fastboot/shoebox" id="shoebox-key6">undefined</script>');
});
});

Expand All @@ -43,6 +46,9 @@ describe("FastBootShoebox", function() {
expect(html).to.include('<script type="fastboot/shoebox" id="shoebox-key4">{"nastyScriptCase":"\\u003cscript\\u003ealert(\'owned\');\\u003c/script\\u003e\\u003c/script\\u003e\\u003c/script\\u003e"}</script>');

expect(html).to.include('<script type="fastboot/shoebox" id="shoebox-key5">{"otherUnicodeChars":"\\u0026\\u0026\\u003e\\u003e\\u003c\\u003c\\u2028\\u2028\\u2029\\u2029"}</script>');

// handles undefined
expect(html).to.include('<script type="fastboot/shoebox" id="shoebox-key6">undefined</script>');
});
});

Expand All @@ -63,6 +69,9 @@ describe("FastBootShoebox", function() {
expect(html).to.not.include('<script type="fastboot/shoebox" id="shoebox-key4">{"nastyScriptCase":"\\u003cscript\\u003ealert(\'owned\');\\u003c/script\\u003e\\u003c/script\\u003e\\u003c/script\\u003e"}</script>');

expect(html).to.not.include('<script type="fastboot/shoebox" id="shoebox-key5">{"otherUnicodeChars":"\\u0026\\u0026\\u003e\\u003e\\u003c\\u003c\\u2028\\u2028\\u2029\\u2029"}</script>');

// handles undefined
expect(html).to.not.include('<script type="fastboot/shoebox" id="shoebox-key6">undefined</script>');
});
});
});
1 change: 1 addition & 0 deletions test/fixtures/shoebox/fastboot/fastboot-test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5fafef8

Please sign in to comment.