@modern-js/server-core 3.5.0 → 3.7.0
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.
|
@@ -91,6 +91,10 @@ function createPublicMiddleware({ pwd, routes }) {
|
|
|
91
91
|
function matchPublicRoute(req, routes) {
|
|
92
92
|
for (const route of routes.sort(index_js_namespaceObject.sortRoutes))if (!route.isSSR && route.entryPath.startsWith('public') && req.path.startsWith(route.urlPath)) return route;
|
|
93
93
|
}
|
|
94
|
+
const isPathInside = (target, root)=>{
|
|
95
|
+
const relative = external_path_default().relative(external_path_default().resolve(root), external_path_default().resolve(target));
|
|
96
|
+
return '' === relative || !relative.startsWith(`..${external_path_default().sep}`) && '..' !== relative && !external_path_default().isAbsolute(relative);
|
|
97
|
+
};
|
|
94
98
|
const extractPathname = (url)=>{
|
|
95
99
|
try {
|
|
96
100
|
if (url.includes('://')) return new URL(url).pathname || '/';
|
|
@@ -141,6 +145,7 @@ function createStaticMiddleware(options) {
|
|
|
141
145
|
})(c, next);
|
|
142
146
|
{
|
|
143
147
|
const filepath = external_path_default().join(pwd, pathname.replace(pathPrefix, ()=>''));
|
|
148
|
+
if (!isPathInside(filepath, pwd)) return next();
|
|
144
149
|
if (!await utils_namespaceObject.fs.pathExists(filepath)) return next();
|
|
145
150
|
const mimeType = (0, mime_namespaceObject.getMimeType)(filepath);
|
|
146
151
|
if (mimeType) c.header('Content-Type', mimeType);
|
|
@@ -47,6 +47,10 @@ function createPublicMiddleware({ pwd, routes }) {
|
|
|
47
47
|
function matchPublicRoute(req, routes) {
|
|
48
48
|
for (const route of routes.sort(sortRoutes))if (!route.isSSR && route.entryPath.startsWith('public') && req.path.startsWith(route.urlPath)) return route;
|
|
49
49
|
}
|
|
50
|
+
const isPathInside = (target, root)=>{
|
|
51
|
+
const relative = path.relative(path.resolve(root), path.resolve(target));
|
|
52
|
+
return '' === relative || !relative.startsWith(`..${path.sep}`) && '..' !== relative && !path.isAbsolute(relative);
|
|
53
|
+
};
|
|
50
54
|
const extractPathname = (url)=>{
|
|
51
55
|
try {
|
|
52
56
|
if (url.includes('://')) return new URL(url).pathname || '/';
|
|
@@ -97,6 +101,7 @@ function createStaticMiddleware(options) {
|
|
|
97
101
|
})(c, next);
|
|
98
102
|
{
|
|
99
103
|
const filepath = path.join(pwd, pathname.replace(pathPrefix, ()=>''));
|
|
104
|
+
if (!isPathInside(filepath, pwd)) return next();
|
|
100
105
|
if (!await fs.pathExists(filepath)) return next();
|
|
101
106
|
const mimeType = getMimeType(filepath);
|
|
102
107
|
if (mimeType) c.header('Content-Type', mimeType);
|
|
@@ -10,7 +10,7 @@ import { ssrRender } from "./ssrRender.mjs";
|
|
|
10
10
|
import { __webpack_require__ } from "../../rslib-runtime.mjs";
|
|
11
11
|
import * as __rspack_external__modern_js_runtime_utils_router_2aa8d96f from "@modern-js/runtime-utils/router";
|
|
12
12
|
__webpack_require__.add({
|
|
13
|
-
|
|
13
|
+
5327 (module) {
|
|
14
14
|
module.exports = __rspack_external__modern_js_runtime_utils_router_2aa8d96f;
|
|
15
15
|
}
|
|
16
16
|
});
|
|
@@ -149,7 +149,7 @@ async function renderHandler(request, options, mode, fallbackWrapper, framework)
|
|
|
149
149
|
const { nestedRoutesJson } = serverManifest;
|
|
150
150
|
const routes = nestedRoutesJson?.[options.routeInfo.entryName];
|
|
151
151
|
if (routes) {
|
|
152
|
-
const { matchRoutes } = __webpack_require__(
|
|
152
|
+
const { matchRoutes } = __webpack_require__(5327);
|
|
153
153
|
const url = new URL(request.url);
|
|
154
154
|
const matchedRoutes = matchRoutes(routes, url.pathname, options.routeInfo.urlPath);
|
|
155
155
|
if (matchedRoutes) {
|
|
@@ -48,6 +48,10 @@ function createPublicMiddleware({ pwd, routes }) {
|
|
|
48
48
|
function matchPublicRoute(req, routes) {
|
|
49
49
|
for (const route of routes.sort(sortRoutes))if (!route.isSSR && route.entryPath.startsWith('public') && req.path.startsWith(route.urlPath)) return route;
|
|
50
50
|
}
|
|
51
|
+
const isPathInside = (target, root)=>{
|
|
52
|
+
const relative = path.relative(path.resolve(root), path.resolve(target));
|
|
53
|
+
return '' === relative || !relative.startsWith(`..${path.sep}`) && '..' !== relative && !path.isAbsolute(relative);
|
|
54
|
+
};
|
|
51
55
|
const extractPathname = (url)=>{
|
|
52
56
|
try {
|
|
53
57
|
if (url.includes('://')) return new URL(url).pathname || '/';
|
|
@@ -98,6 +102,7 @@ function createStaticMiddleware(options) {
|
|
|
98
102
|
})(c, next);
|
|
99
103
|
{
|
|
100
104
|
const filepath = path.join(pwd, pathname.replace(pathPrefix, ()=>''));
|
|
105
|
+
if (!isPathInside(filepath, pwd)) return next();
|
|
101
106
|
if (!await fs.pathExists(filepath)) return next();
|
|
102
107
|
const mimeType = getMimeType(filepath);
|
|
103
108
|
if (mimeType) c.header('Content-Type', mimeType);
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "3.
|
|
18
|
+
"version": "3.7.0",
|
|
19
19
|
"types": "./dist/types/index.d.ts",
|
|
20
20
|
"main": "./dist/cjs/index.js",
|
|
21
21
|
"exports": {
|
|
@@ -71,20 +71,20 @@
|
|
|
71
71
|
"flatted": "^3.4.2",
|
|
72
72
|
"hono": "^4.11.7",
|
|
73
73
|
"ts-deepmerge": "7.0.3",
|
|
74
|
-
"@modern-js/plugin": "3.
|
|
75
|
-
"@modern-js/runtime-utils": "3.
|
|
76
|
-
"@modern-js/utils": "3.
|
|
74
|
+
"@modern-js/plugin": "3.7.0",
|
|
75
|
+
"@modern-js/runtime-utils": "3.7.0",
|
|
76
|
+
"@modern-js/utils": "3.7.0"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@rslib/core": "0.23.
|
|
79
|
+
"@rslib/core": "0.23.2",
|
|
80
80
|
"@types/cloneable-readable": "^2.0.3",
|
|
81
81
|
"@types/merge-deep": "^3.0.3",
|
|
82
82
|
"@types/node": "^20",
|
|
83
|
-
"http-proxy-middleware": "^2.0.
|
|
83
|
+
"http-proxy-middleware": "^2.0.10",
|
|
84
84
|
"typescript": "^5",
|
|
85
|
+
"@scripts/rstest-config": "2.66.0",
|
|
85
86
|
"@modern-js/rslib": "2.68.10",
|
|
86
|
-
"@modern-js/types": "3.
|
|
87
|
-
"@scripts/rstest-config": "2.66.0"
|
|
87
|
+
"@modern-js/types": "3.7.0"
|
|
88
88
|
},
|
|
89
89
|
"sideEffects": false,
|
|
90
90
|
"publishConfig": {
|