You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The use of path.extname to extract the extension of a require (done here) is actually an inherent bug, as path does the extension extract based on the assumption that the entire string is a pure filename, whereas node requires don't have to conform to these. Webpack loaders take advantage of this, so you can do something like this:
require("file!basefile.txt?name=monkey.d.luffy");
Which will copy the "basefile.txt" resource as the file "monkey.d.luffy" somewhere else. In strings like these, path cannot extract the extension, as it assumes the strings is a true file path rather than a URI, and so it will find .luffy as extension.
It would probably worth to at the very least strip off URI arguments, using something like
function shouldCompile(filename, exts, matcher, ignoreNodeModules) {
if (typeof filename !== 'string') return false;
// strip URI arguments if necessary (used by webpack etc.)
var qpos = filename.indexOf('?');
if (qpos > -1) filename = filename.substring(0,qpos);
if (exts.indexOf(path.extname(filename)) === -1) return false;
filename = path.resolve(filename);
if (ignoreNodeModules && nodeModulesRegex.test(filename)) return false;
if (matcher && typeof matcher === 'function') return !!matcher(filename);
return true;
}```
The text was updated successfully, but these errors were encountered:
The use of path.extname to extract the extension of a require (done here) is actually an inherent bug, as
path
does the extension extract based on the assumption that the entire string is a pure filename, whereas node requires don't have to conform to these. Webpack loaders take advantage of this, so you can do something like this:Which will copy the "basefile.txt" resource as the file "monkey.d.luffy" somewhere else. In strings like these,
path
cannot extract the extension, as it assumes the strings is a true file path rather than a URI, and so it will find.luffy
as extension.It would probably worth to at the very least strip off URI arguments, using something like
The text was updated successfully, but these errors were encountered: