@umijs/bundler-webpack 4.6.64 → 4.6.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/server.js +9 -1
- package/dist/server/utils.d.ts +1 -0
- package/dist/server/utils.js +38 -0
- package/package.json +5 -5
package/dist/server/server.js
CHANGED
|
@@ -41,6 +41,7 @@ var import_fs = require("fs");
|
|
|
41
41
|
var import_http = __toESM(require("http"));
|
|
42
42
|
var import_path = require("path");
|
|
43
43
|
var import_constants = require("../constants");
|
|
44
|
+
var import_utils2 = require("./utils");
|
|
44
45
|
var import_ws = require("./ws");
|
|
45
46
|
async function createServer(opts) {
|
|
46
47
|
const { webpackConfig, userConfig } = opts;
|
|
@@ -59,7 +60,14 @@ async function createServer(opts) {
|
|
|
59
60
|
}
|
|
60
61
|
app.use((req, res, next) => {
|
|
61
62
|
const file = req.path;
|
|
62
|
-
const filePath = (0,
|
|
63
|
+
const filePath = (0, import_utils2.resolvePathWithinRoot)(opts.cwd, file);
|
|
64
|
+
if (!filePath) {
|
|
65
|
+
if ((0, import_path.extname)(file) === ".js") {
|
|
66
|
+
res.status(403).end("Forbidden");
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
return next();
|
|
70
|
+
}
|
|
63
71
|
const ext = (0, import_path.extname)(filePath);
|
|
64
72
|
if (ext === ".js" && (0, import_fs.existsSync)(filePath)) {
|
|
65
73
|
import_utils.logger.info(
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolvePathWithinRoot(root: string, file: string): string | null;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/server/utils.ts
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
resolvePathWithinRoot: () => resolvePathWithinRoot
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(utils_exports);
|
|
25
|
+
var import_path = require("path");
|
|
26
|
+
function resolvePathWithinRoot(root, file) {
|
|
27
|
+
const resolvedRoot = (0, import_path.resolve)(root);
|
|
28
|
+
const filePath = (0, import_path.resolve)(resolvedRoot, `.${file}`);
|
|
29
|
+
const relativePath = (0, import_path.relative)(resolvedRoot, filePath);
|
|
30
|
+
if (relativePath === ".." || relativePath.startsWith(`..${import_path.sep}`) || (0, import_path.isAbsolute)(relativePath)) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return filePath;
|
|
34
|
+
}
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
resolvePathWithinRoot
|
|
38
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-webpack",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.66",
|
|
4
4
|
"description": "@umijs/bundler-webpack",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/bundler-webpack#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"postcss-preset-env": "7.5.0",
|
|
39
39
|
"react-error-overlay": "6.0.9",
|
|
40
40
|
"react-refresh": "0.14.0",
|
|
41
|
-
"@umijs/
|
|
42
|
-
"@umijs/utils": "4.6.
|
|
43
|
-
"@umijs/mfsu": "4.6.
|
|
44
|
-
"@umijs/
|
|
41
|
+
"@umijs/babel-preset-umi": "4.6.66",
|
|
42
|
+
"@umijs/utils": "4.6.66",
|
|
43
|
+
"@umijs/mfsu": "4.6.66",
|
|
44
|
+
"@umijs/bundler-utils": "4.6.66"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@swc/core": "1.3.67",
|