astro 7.0.4 → 7.0.6
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/components/Picture.astro +19 -2
- package/dist/actions/handler.js +7 -0
- package/dist/cli/dev/background.js +4 -2
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/cli/install-package.js +5 -3
- package/dist/container/index.js +4 -2
- package/dist/content/content-layer.js +3 -3
- package/dist/core/app/origin-check.d.ts +32 -0
- package/dist/core/app/origin-check.js +52 -0
- package/dist/core/base-pipeline.js +1 -1
- package/dist/core/build/plugins/index.js +2 -0
- package/dist/core/build/plugins/plugin-css-target-lowering.d.ts +14 -0
- package/dist/core/build/plugins/plugin-css-target-lowering.js +82 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +2 -0
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/fetch/fetch-state.js +2 -0
- package/dist/core/head-propagation/buffer.d.ts +14 -3
- package/dist/core/head-propagation/buffer.js +17 -7
- package/dist/core/messages/runtime.js +1 -1
- package/dist/core/pages/handler.js +9 -1
- package/dist/core/routing/generator.js +2 -2
- package/dist/core/util.d.ts +8 -0
- package/dist/core/util.js +23 -0
- package/dist/core/viteUtils.d.ts +3 -0
- package/dist/core/viteUtils.js +8 -2
- package/dist/prefetch/index.js +10 -0
- package/dist/runtime/server/render/astro/instance.js +3 -0
- package/dist/runtime/server/render/common.js +7 -1
- package/dist/runtime/server/render/dom.js +4 -1
- package/dist/runtime/server/render/instruction.d.ts +1 -0
- package/dist/runtime/server/render/instruction.js +5 -1
- package/dist/runtime/server/render/page.js +7 -2
- package/dist/runtime/server/render/server-islands-shared.d.ts +1 -0
- package/dist/runtime/server/render/server-islands-shared.js +4 -0
- package/dist/runtime/server/render/server-islands.js +9 -8
- package/dist/runtime/server/render/slot.d.ts +15 -2
- package/dist/runtime/server/render/slot.js +37 -6
- package/dist/runtime/server/render/util.d.ts +1 -0
- package/dist/runtime/server/render/util.js +1 -0
- package/dist/template/4xx.js +1 -1
- package/dist/transitions/swap-functions.js +9 -2
- package/dist/types/public/internal.d.ts +14 -0
- package/dist/vite-plugin-astro/index.js +3 -1
- package/dist/vite-plugin-astro-server/plugin.js +3 -0
- package/dist/vite-plugin-config-alias/index.d.ts +19 -1
- package/dist/vite-plugin-config-alias/index.js +6 -5
- package/dist/vite-plugin-css/index.js +1 -1
- package/dist/vite-plugin-html/transform/index.js +16 -7
- package/dist/vite-plugin-html/transform/slots.d.ts +10 -7
- package/dist/vite-plugin-html/transform/slots.js +19 -26
- package/dist/vite-plugin-html/transform/utils.d.ts +0 -3
- package/dist/vite-plugin-html/transform/utils.js +1 -20
- package/package.json +5 -10
- package/templates/content/types.d.ts +4 -0
- package/dist/core/app/middlewares.d.ts +0 -8
- package/dist/core/app/middlewares.js +0 -49
- package/dist/vite-plugin-html/transform/escape.d.ts +0 -7
- package/dist/vite-plugin-html/transform/escape.js +0 -30
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { defineMiddleware } from "../middleware/defineMiddleware.js";
|
|
2
|
-
const FORM_CONTENT_TYPES = [
|
|
3
|
-
"application/x-www-form-urlencoded",
|
|
4
|
-
"multipart/form-data",
|
|
5
|
-
"text/plain"
|
|
6
|
-
];
|
|
7
|
-
const SAFE_METHODS = ["GET", "HEAD", "OPTIONS"];
|
|
8
|
-
function createOriginCheckMiddleware() {
|
|
9
|
-
return defineMiddleware((context, next) => {
|
|
10
|
-
const { request, url, isPrerendered } = context;
|
|
11
|
-
if (isPrerendered) {
|
|
12
|
-
return next();
|
|
13
|
-
}
|
|
14
|
-
if (SAFE_METHODS.includes(request.method)) {
|
|
15
|
-
return next();
|
|
16
|
-
}
|
|
17
|
-
const isSameOrigin = request.headers.get("origin") === url.origin;
|
|
18
|
-
const hasContentType = request.headers.has("content-type");
|
|
19
|
-
if (hasContentType) {
|
|
20
|
-
const formLikeHeader = hasFormLikeHeader(request.headers.get("content-type"));
|
|
21
|
-
if (formLikeHeader && !isSameOrigin) {
|
|
22
|
-
return new Response(`Cross-site ${request.method} form submissions are forbidden`, {
|
|
23
|
-
status: 403
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
} else {
|
|
27
|
-
if (!isSameOrigin) {
|
|
28
|
-
return new Response(`Cross-site ${request.method} form submissions are forbidden`, {
|
|
29
|
-
status: 403
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return next();
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
function hasFormLikeHeader(contentType) {
|
|
37
|
-
if (contentType) {
|
|
38
|
-
for (const FORM_CONTENT_TYPE of FORM_CONTENT_TYPES) {
|
|
39
|
-
if (contentType.toLowerCase().includes(FORM_CONTENT_TYPE)) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
export {
|
|
47
|
-
createOriginCheckMiddleware,
|
|
48
|
-
hasFormLikeHeader
|
|
49
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { visit } from "unist-util-visit";
|
|
2
|
-
import { escapeTemplateLiteralCharacters, needsEscape, replaceAttribute } from "./utils.js";
|
|
3
|
-
const rehypeEscape = ({ s }) => {
|
|
4
|
-
return (tree) => {
|
|
5
|
-
visit(tree, (node) => {
|
|
6
|
-
if (node.type === "text" || node.type === "comment") {
|
|
7
|
-
if (needsEscape(node.value)) {
|
|
8
|
-
s.overwrite(
|
|
9
|
-
node.position.start.offset,
|
|
10
|
-
node.position.end.offset,
|
|
11
|
-
escapeTemplateLiteralCharacters(node.value)
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
} else if (node.type === "element") {
|
|
15
|
-
if (!node.properties) return;
|
|
16
|
-
for (let [key, value] of Object.entries(node.properties)) {
|
|
17
|
-
key = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
18
|
-
const newKey = needsEscape(key) ? escapeTemplateLiteralCharacters(key) : key;
|
|
19
|
-
const newValue = needsEscape(value) ? escapeTemplateLiteralCharacters(value) : value;
|
|
20
|
-
if (newKey === key && newValue === value) continue;
|
|
21
|
-
replaceAttribute(s, node, key, value === "" ? newKey : `${newKey}="${newValue}"`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
var escape_default = rehypeEscape;
|
|
28
|
-
export {
|
|
29
|
-
escape_default as default
|
|
30
|
-
};
|