Skip to content

Commit 1941aaa

Browse files
authored
Merge pull request mozilla#283 from tromey/json-xssi-avoidance
Remove entire first line when JSON XSSI prevention seen
2 parents eb182f0 + de68f7f commit 1941aaa

14 files changed

+136
-36
lines changed

dist/source-map.debug.js

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

dist/source-map.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,16 @@ return /******/ (function(modules) { // webpackBootstrap
11441144
}
11451145
exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
11461146

1147+
/**
1148+
* Strip any JSON XSSI avoidance prefix from the string (as documented
1149+
* in the source maps specification), and then parse the string as
1150+
* JSON.
1151+
*/
1152+
function parseSourceMapInput(str) {
1153+
return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
1154+
}
1155+
exports.parseSourceMapInput = parseSourceMapInput;
1156+
11471157

11481158
/***/ }),
11491159
/* 5 */
@@ -1377,7 +1387,7 @@ return /******/ (function(modules) { // webpackBootstrap
13771387
function SourceMapConsumer(aSourceMap) {
13781388
var sourceMap = aSourceMap;
13791389
if (typeof aSourceMap === 'string') {
1380-
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
1390+
sourceMap = util.parseSourceMapInput(aSourceMap);
13811391
}
13821392

13831393
return sourceMap.sections != null
@@ -1652,7 +1662,7 @@ return /******/ (function(modules) { // webpackBootstrap
16521662
function BasicSourceMapConsumer(aSourceMap) {
16531663
var sourceMap = aSourceMap;
16541664
if (typeof aSourceMap === 'string') {
1655-
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
1665+
sourceMap = util.parseSourceMapInput(aSourceMap);
16561666
}
16571667

16581668
var version = util.getArg(sourceMap, 'version');
@@ -2205,7 +2215,7 @@ return /******/ (function(modules) { // webpackBootstrap
22052215
function IndexedSourceMapConsumer(aSourceMap) {
22062216
var sourceMap = aSourceMap;
22072217
if (typeof aSourceMap === 'string') {
2208-
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
2218+
sourceMap = util.parseSourceMapInput(aSourceMap);
22092219
}
22102220

22112221
var version = util.getArg(sourceMap, 'version');

dist/source-map.min.js

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

dist/source-map.min.js.map

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

dist/test/test_api.js

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

dist/test/test_array_set.js

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/test/test_dog_fooding.js

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

dist/test/test_source_map_consumer.js

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

dist/test/test_source_map_generator.js

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

dist/test/test_source_node.js

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

0 commit comments

Comments
 (0)