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

False positives (REGEX) in SourcemappingUrlProcessor when having ".map" in path #496

Open
jose-miguel-cruz opened this issue Jan 7, 2022 · 2 comments

Comments

@jose-miguel-cruz
Copy link

We have a JS asset that contains some generic polyfills from @babel/polyfill

From this Sprockets v3.4.0 update, our application stopped working

We found the issue occurs when we use source-maps for specific functions that have .map in the path like "../node_modules/core-js/modules/es6.array.map.js"

Original code:

/***/ "../node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.map.js":
/*!*************************************************************************************!*\
  !*** ../node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.map.js ***!
  \*************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
eval("\nvar $export = __webpack_require__(/*! ./_export */ \"../node_modules/@babel/polyfill/node_modules/core-js/modules/_export.js\");\nvar $map = __webpack_require__(/*! ./_array-methods */ \"../node_modules/@babel/polyfill/node_modules/core-js/modules/_array-methods.js\")(1);\n\n$export($export.P + $export.F * !__webpack_require__(/*! ./_strict-method */ \"../node_modules/@babel/polyfill/node_modules/core-js/modules/_strict-method.js\")([].map, true), 'Array', {\n  // 22.1.3.15 / 15.4.4.19 Array.prototype.map(callbackfn [, thisArg])\n  map: function map(callbackfn /* , thisArg */) {\n    return $map(this, callbackfn, arguments[1]);\n  }\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vLi4vbm9kZV9tb2R1bGVzL0BiYWJlbC9wb2x5ZmlsbC9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzL2VzNi5hcnJheS5tYXAuanM/NDY4YyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBYTtBQUNiLGNBQWMsbUJBQU8sQ0FBQywwRkFBVztBQUNqQyxXQUFXLG1CQUFPLENBQUMsd0dBQWtCOztBQUVyQyxpQ0FBaUMsbUJBQU8sQ0FBQyx3R0FBa0I7QUFDM0Q7QUFDQTtBQUNBO0FBQ0E7QUFDQSxDQUFDIiwiZmlsZSI6Ii4uL25vZGVfbW9kdWxlcy9AYmFiZWwvcG9seWZpbGwvbm9kZV9tb2R1bGVzL2NvcmUtanMvbW9kdWxlcy9lczYuYXJyYXkubWFwLmpzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiJ3VzZSBzdHJpY3QnO1xudmFyICRleHBvcnQgPSByZXF1aXJlKCcuL19leHBvcnQnKTtcbnZhciAkbWFwID0gcmVxdWlyZSgnLi9fYXJyYXktbWV0aG9kcycpKDEpO1xuXG4kZXhwb3J0KCRleHBvcnQuUCArICRleHBvcnQuRiAqICFyZXF1aXJlKCcuL19zdHJpY3QtbWV0aG9kJykoW10ubWFwLCB0cnVlKSwgJ0FycmF5Jywge1xuICAvLyAyMi4xLjMuMTUgLyAxNS40LjQuMTkgQXJyYXkucHJvdG90eXBlLm1hcChjYWxsYmFja2ZuIFssIHRoaXNBcmddKVxuICBtYXA6IGZ1bmN0aW9uIG1hcChjYWxsYmFja2ZuIC8qICwgdGhpc0FyZyAqLykge1xuICAgIHJldHVybiAkbWFwKHRoaXMsIGNhbGxiYWNrZm4sIGFyZ3VtZW50c1sxXSk7XG4gIH1cbn0pO1xuIl0sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///../node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.map.js\n");

/***/ }),
Using this REGEX \/\/# sourceMappingURL=(.*\.map) then generates false positives:

image

And finally will lead to an output like this, which will make the application crash:

(From: <application_path>/assets/application.js)

image

@arunrao86
Copy link

@jose-miguel-cruz ,Was there any workaround for this? Even in the latest version 3.4.2, this issue is still present.

@miguel-101
Copy link

@arunrao86, unfortunately, no, we had to pin to version 3.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants