Skip to content

Commit 9a4aa1c

Browse files
author
Kelly Selden
committed
handle undefined in shoebox
1 parent c60c8c8 commit 9a4aa1c

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/ember-app.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,8 @@ function createShoebox(doc, fastbootInfo) {
422422

423423
let value = shoebox[key];
424424
let textValue = JSON.stringify(value);
425+
if (textValue === undefined) { continue; }
426+
425427
textValue = escapeJSONString(textValue);
426428

427429
let scriptText = doc.createRawHTMLSection(textValue);

test/fastboot-shoebox-test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ describe("FastBootShoebox", function() {
2323
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>');
2424

2525
expect(html).to.include('<script type="fastboot/shoebox" id="shoebox-key5">{"otherUnicodeChars":"\\u0026\\u0026\\u003e\\u003e\\u003c\\u003c\\u2028\\u2028\\u2029\\u2029"}</script>');
26+
27+
// ignores undefined
28+
expect(html).to.not.include('shoebox-key6');
2629
});
2730
});
2831

@@ -43,6 +46,9 @@ describe("FastBootShoebox", function() {
4346
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>');
4447

4548
expect(html).to.include('<script type="fastboot/shoebox" id="shoebox-key5">{"otherUnicodeChars":"\\u0026\\u0026\\u003e\\u003e\\u003c\\u003c\\u2028\\u2028\\u2029\\u2029"}</script>');
49+
50+
// ignores undefined
51+
expect(html).to.not.include('shoebox-key6');
4652
});
4753
});
4854

@@ -63,6 +69,9 @@ describe("FastBootShoebox", function() {
6369
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>');
6470

6571
expect(html).to.not.include('<script type="fastboot/shoebox" id="shoebox-key5">{"otherUnicodeChars":"\\u0026\\u0026\\u003e\\u003e\\u003c\\u003c\\u2028\\u2028\\u2029\\u2029"}</script>');
72+
73+
// ignores undefined
74+
expect(html).to.not.include('shoebox-key6');
6675
});
6776
});
6877
});

test/fixtures/shoebox/fastboot/fastboot-test.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)