@ereo/plugin-images 0.1.22 → 0.1.24

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/index.js CHANGED
@@ -4253,7 +4253,7 @@ async function optimizeImages(options) {
4253
4253
 
4254
4254
  // src/runtime/middleware.ts
4255
4255
  import { readFile as readFile5 } from "fs/promises";
4256
- import { join as join5 } from "path";
4256
+ import { join as join5, resolve, normalize } from "path";
4257
4257
 
4258
4258
  // src/runtime/cache.ts
4259
4259
  import { readFile as readFile4, writeFile as writeFile3, mkdir as mkdir3, unlink, readdir as readdir2, stat as stat3 } from "fs/promises";
@@ -4647,7 +4647,11 @@ function createImageMiddleware(options) {
4647
4647
  }
4648
4648
  sourceBuffer = Buffer.from(await response.arrayBuffer());
4649
4649
  } else {
4650
- const localPath = params.src.startsWith("/") ? join5(options.root, "public", params.src) : join5(options.root, params.src);
4650
+ const baseDir = resolve(options.root, "public");
4651
+ const localPath = resolve(baseDir, normalize(params.src.replace(/^\//, "")));
4652
+ if (!localPath.startsWith(baseDir)) {
4653
+ return new Response("Forbidden", { status: 403 });
4654
+ }
4651
4655
  try {
4652
4656
  sourceBuffer = await readFile5(localPath);
4653
4657
  } catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/runtime/middleware.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAA2B,MAAM,qBAAqB,CAAC;AAatF;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,qBAAqB;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA6GD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,IAsBjE,SAAS,OAAO,EAChB,SAAS,UAAU,EACnB,MAAM,MAAM,OAAO,CAAC,QAAQ,CAAC,KAC5B,OAAO,CAAC,QAAQ,CAAC,CA8ErB;AA+BD;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,iBAAiB,CAUlF"}
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/runtime/middleware.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAA2B,MAAM,qBAAqB,CAAC;AAatF;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,qBAAqB;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA6GD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,IAsBjE,SAAS,OAAO,EAChB,SAAS,UAAU,EACnB,MAAM,MAAM,OAAO,CAAC,QAAQ,CAAC,KAC5B,OAAO,CAAC,QAAQ,CAAC,CAkFrB;AA+BD;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,iBAAiB,CAUlF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ereo/plugin-images",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "license": "MIT",
5
5
  "author": "Ereo Team",
6
6
  "homepage": "https://ereo.dev",
@@ -36,7 +36,7 @@
36
36
  "typecheck": "tsc --noEmit"
37
37
  },
38
38
  "dependencies": {
39
- "@ereo/core": "^0.1.22",
39
+ "@ereo/core": "^0.1.24",
40
40
  "sharp": "^0.33.0"
41
41
  },
42
42
  "devDependencies": {