astro 6.4.5 → 6.4.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.
@@ -1,6 +1,6 @@
1
1
  class BuildTimeAstroVersionProvider {
2
2
  // Injected during the build through esbuild define
3
- version = "6.4.5";
3
+ version = "6.4.6";
4
4
  }
5
5
  export {
6
6
  BuildTimeAstroVersionProvider
@@ -197,7 +197,7 @@ ${contentConfig.error.message}`
197
197
  logger.info("Content config changed");
198
198
  shouldClear = true;
199
199
  }
200
- if (previousAstroVersion && previousAstroVersion !== "6.4.5") {
200
+ if (previousAstroVersion && previousAstroVersion !== "6.4.6") {
201
201
  logger.info("Astro version changed");
202
202
  shouldClear = true;
203
203
  }
@@ -205,8 +205,8 @@ ${contentConfig.error.message}`
205
205
  logger.info("Clearing content store");
206
206
  this.#store.clearAll();
207
207
  }
208
- if ("6.4.5") {
209
- this.#store.metaStore().set("astro-version", "6.4.5");
208
+ if ("6.4.6") {
209
+ this.#store.metaStore().set("astro-version", "6.4.6");
210
210
  }
211
211
  if (currentConfigDigest) {
212
212
  this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -23,6 +23,25 @@ import {
23
23
  } from "./consts.js";
24
24
  import { getDataStoreFile } from "./content-layer.js";
25
25
  import { getContentPaths, isDeferredModule } from "./utils.js";
26
+ function invalidateAssetImports(viteServer, filePath) {
27
+ const timestamp = Date.now();
28
+ for (const environment of Object.values(viteServer.environments)) {
29
+ const modules = environment.moduleGraph.getModulesByFile(filePath);
30
+ if (modules) {
31
+ for (const module of modules) {
32
+ environment.moduleGraph.invalidateModule(module, void 0, timestamp, true);
33
+ }
34
+ }
35
+ if (isRunnableDevEnvironment(environment)) {
36
+ const runnerModules = environment.runner.evaluatedModules.getModulesByFile(filePath);
37
+ if (runnerModules) {
38
+ for (const runnerModule of runnerModules) {
39
+ environment.runner.evaluatedModules.invalidateModule(runnerModule);
40
+ }
41
+ }
42
+ }
43
+ }
44
+ }
26
45
  function invalidateDataStore(viteServer) {
27
46
  const environment = viteServer.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr];
28
47
  const module = environment.moduleGraph.getModuleById(RESOLVED_DATA_STORE_VIRTUAL_ID);
@@ -67,8 +86,11 @@ function astroContentVirtualModPlugin({
67
86
  },
68
87
  buildStart() {
69
88
  if (devServer) {
89
+ const assetImportsPath = fileURLToPath(new URL(ASSET_IMPORTS_FILE, settings.dotAstroDir));
70
90
  devServer.watcher.add(fileURLToPath(dataStoreFile));
91
+ devServer.watcher.add(assetImportsPath);
71
92
  invalidateDataStore(devServer);
93
+ invalidateAssetImports(devServer, assetImportsPath);
72
94
  }
73
95
  },
74
96
  resolveId: {
@@ -175,14 +197,19 @@ function astroContentVirtualModPlugin({
175
197
  configureServer(server) {
176
198
  devServer = server;
177
199
  const dataStorePath = fileURLToPath(dataStoreFile);
200
+ const assetImportsPath = fileURLToPath(new URL(ASSET_IMPORTS_FILE, settings.dotAstroDir));
178
201
  server.watcher.on("add", (addedPath) => {
179
202
  if (addedPath === dataStorePath) {
180
203
  invalidateDataStore(server);
204
+ invalidateAssetImports(server, assetImportsPath);
181
205
  }
182
206
  });
183
207
  server.watcher.on("change", (changedPath) => {
184
208
  if (changedPath === dataStorePath) {
185
209
  invalidateDataStore(server);
210
+ invalidateAssetImports(server, assetImportsPath);
211
+ } else if (changedPath === assetImportsPath) {
212
+ invalidateAssetImports(server, assetImportsPath);
186
213
  }
187
214
  });
188
215
  }
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "6.4.5";
1
+ const ASTRO_VERSION = "6.4.6";
2
2
  const ASTRO_GENERATOR = `Astro v${ASTRO_VERSION}`;
3
3
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
4
4
  const REWRITE_DIRECTIVE_HEADER_KEY = "X-Astro-Rewrite";
@@ -37,7 +37,7 @@ async function dev(inlineConfig) {
37
37
  await telemetry.record([]);
38
38
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
39
39
  const logger = restart.container.logger;
40
- const currentVersion = "6.4.5";
40
+ const currentVersion = "6.4.6";
41
41
  const isPrerelease = currentVersion.includes("-");
42
42
  if (!isPrerelease) {
43
43
  try {
@@ -6,6 +6,7 @@ import { AstroMiddleware } from "../middleware/astro-middleware.js";
6
6
  import { PagesHandler } from "../pages/handler.js";
7
7
  import { matchRoute } from "../routing/match.js";
8
8
  import { provideSession } from "../session/handler.js";
9
+ import { validateHost } from "../app/validate-headers.js";
9
10
  class DefaultErrorHandler {
10
11
  #app;
11
12
  #astroMiddleware;
@@ -31,15 +32,27 @@ class DefaultErrorHandler {
31
32
  if (errorRouteData) {
32
33
  if (errorRouteData.prerender) {
33
34
  const maybeDotHtml = errorRouteData.route.endsWith(`/${status}`) ? ".html" : "";
34
- const statusURL = new URL(`${app.baseWithoutTrailingSlash}/${status}${maybeDotHtml}`, url);
35
+ const allowedDomains = app.manifest.allowedDomains;
36
+ const validatedHost = validateHost(url.host, url.protocol.replace(":", ""), allowedDomains);
37
+ const safeOrigin = validatedHost ? url.origin : `${url.protocol}//localhost`;
38
+ const statusURL = new URL(
39
+ `${app.baseWithoutTrailingSlash}/${status}${maybeDotHtml}`,
40
+ safeOrigin
41
+ );
35
42
  if (statusURL.toString() !== request.url && resolvedRenderOptions.prerenderedErrorPageFetch) {
36
- const response2 = await resolvedRenderOptions.prerenderedErrorPageFetch(
37
- statusURL.toString()
38
- );
39
- const override = { status, removeContentEncodingHeaders: true };
40
- const newResponse = mergeResponses(response2, originalResponse, override);
41
- prepareResponse(newResponse, resolvedRenderOptions);
42
- return newResponse;
43
+ try {
44
+ const response2 = await resolvedRenderOptions.prerenderedErrorPageFetch(
45
+ statusURL.toString()
46
+ );
47
+ const override = { status, removeContentEncodingHeaders: true };
48
+ const newResponse = mergeResponses(response2, originalResponse, override);
49
+ prepareResponse(newResponse, resolvedRenderOptions);
50
+ return newResponse;
51
+ } catch {
52
+ const response2 = mergeResponses(new Response(null, { status }), originalResponse);
53
+ prepareResponse(response2, resolvedRenderOptions);
54
+ return response2;
55
+ }
43
56
  }
44
57
  }
45
58
  const mod = await app.pipeline.getComponentByRoute(errorRouteData);
@@ -276,7 +276,7 @@ function printHelp({
276
276
  message.push(
277
277
  linebreak(),
278
278
  ` ${bgGreen(black(` ${commandName} `))} ${green(
279
- `v${"6.4.5"}`
279
+ `v${"6.4.6"}`
280
280
  )} ${headline}`
281
281
  );
282
282
  }
@@ -6,6 +6,7 @@ const htmlBooleanAttributes = /^(?:allowfullscreen|async|autofocus|autoplay|chec
6
6
  const AMPERSAND_REGEX = /&/g;
7
7
  const DOUBLE_QUOTE_REGEX = /"/g;
8
8
  const STATIC_DIRECTIVES = /* @__PURE__ */ new Set(["set:html", "set:text"]);
9
+ const INVALID_ATTR_NAME_CHAR = /[\s"'>/=]/;
9
10
  const toIdent = (k) => k.trim().replace(/(?!^)\b\w|\s+|\W+/g, (match, index) => {
10
11
  if (/\W/.test(match)) return "";
11
12
  return index === 0 ? match : match.toUpperCase();
@@ -43,6 +44,9 @@ function addAttribute(value, key, shouldEscape = true, tagName = "") {
43
44
  if (value == null) {
44
45
  return "";
45
46
  }
47
+ if (INVALID_ATTR_NAME_CHAR.test(key)) {
48
+ return "";
49
+ }
46
50
  if (STATIC_DIRECTIVES.has(key)) {
47
51
  console.warn(`[astro] The "${key}" directive cannot be applied dynamically at runtime. It will not be rendered as an attribute.
48
52
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "6.4.5",
3
+ "version": "6.4.6",
4
4
  "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
5
5
  "type": "module",
6
6
  "author": "withastro",
@@ -166,8 +166,8 @@
166
166
  "yargs-parser": "^22.0.0",
167
167
  "zod": "^4.3.6",
168
168
  "@astrojs/internal-helpers": "0.10.0",
169
- "@astrojs/markdown-remark": "7.2.0",
170
- "@astrojs/telemetry": "3.3.2"
169
+ "@astrojs/telemetry": "3.3.2",
170
+ "@astrojs/markdown-remark": "7.2.0"
171
171
  },
172
172
  "optionalDependencies": {
173
173
  "sharp": "^0.34.0"
@@ -203,8 +203,8 @@
203
203
  "undici": "^7.22.0",
204
204
  "unified": "^11.0.5",
205
205
  "vitest": "^4.1.0",
206
- "@astrojs/check": "0.9.9",
207
- "astro-scripts": "0.0.14"
206
+ "astro-scripts": "0.0.14",
207
+ "@astrojs/check": "0.9.9"
208
208
  },
209
209
  "engines": {
210
210
  "node": ">=22.12.0",