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 27, 2017
1 parent acbb306 commit 2939f47
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ember-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,8 @@ function createShoebox(doc, fastbootInfo) {

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

textValue = escapeJSONString(textValue);

let scriptText = doc.createRawHTMLSection(textValue);
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>');

// ignores undefined
expect(html).to.not.include('shoebox-key6');
});
});

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>');

// ignores undefined
expect(html).to.not.include('shoebox-key6');
});
});

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>');

// ignores undefined
expect(html).to.not.include('shoebox-key6');
});
});
});
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 2939f47

Please sign in to comment.