Skip to content

Tighten image endpoint path handling#16544

Merged
matthewp merged 2 commits into
mainfrom
image-endpoint-cleanup
May 8, 2026
Merged

Tighten image endpoint path handling#16544
matthewp merged 2 commits into
mainfrom
image-endpoint-cleanup

Conversation

@matthewp
Copy link
Copy Markdown
Contributor

Changes

  • isRemotePath() now uses a positive allowlist (/^\/[a-zA-Z0-9._@-]/) for the Unix absolute path early-return instead of a negative check against / and \. Control characters like CR, LF, and tab after a leading slash no longer short-circuit as "local".
  • The dev image endpoint origin check in loadLocalImage now return undefined instead of setting a variable and falling through to loadRemoteImage.

Testing

  • Added 8 cases to the remotePaths array in packages/internal-helpers/test/path.test.ts covering URL-encoded and literal CRLF/LF/CR/tab injection after a leading slash.

Docs

  • No docs changes needed — internal behavior only.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 30, 2026

🦋 Changeset detected

Latest commit: 87dcb8d

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the pkg: astro Related to the core `astro` package (scope) label Apr 30, 2026
// This is only allowed if this is the same origin
if (sourceUrl.origin !== url.origin) {
returnValue = undefined;
return undefined;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was dead-code before, always would try to load the remote image.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 30, 2026

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing image-endpoint-cleanup (87dcb8d) with main (5cf6c51)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (c1fe832) during the generation of this report, so 5cf6c51 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@matthewp matthewp marked this pull request as ready for review April 30, 2026 19:17
@matthewp matthewp merged commit d365c97 into main May 8, 2026
27 checks passed
@matthewp matthewp deleted the image-endpoint-cleanup branch May 8, 2026 15:48
@astrobot-houston astrobot-houston mentioned this pull request May 8, 2026
dadezzz pushed a commit to dadezzz/university_notes that referenced this pull request May 17, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`6.3.1` → `6.3.2`](https://renovatebot.com/diffs/npm/astro/6.3.1/6.3.2) | ![age](https://developer.mend.io/api/mc/badges/age/npm/astro/6.3.2?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/astro/6.3.1/6.3.2?slim=true) |

---

### Release Notes

<details>
<summary>withastro/astro (astro)</summary>

### [`v6.3.2`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#632)

[Compare Source](https://github.com/withastro/astro/compare/astro@6.3.1...astro@6.3.2)

##### Patch Changes

- [#&#8203;16675](withastro/astro#16675) [`11d4592`](withastro/astro@11d4592) Thanks [@&#8203;ascorbic](https://github.com/ascorbic)! - Fixes a regression where `Astro.cache` was `undefined` when `experimental.cache` was not configured.

  The previous documented behavior is for `Astro.cache` to always be defined as a no-op shim: `cache.set()` warns once, `cache.invalidate()` throws and `cache.enabled` can be used to gate. This allows library and user code can call cache methods without conditional checks. The cache provider registration was being gated at the call site on `experimental.cache` being configured, which meant the disabled shim branch inside the provider was unreachable and the `Astro.cache` getter was never attached to the context.

- [#&#8203;16691](withastro/astro#16691) [`0f0a4ce`](withastro/astro@0f0a4ce) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fixes `HTMLElement is not defined` error during HMR when using components with client-side scripts (e.g. Starlight `<Tabs>`) and the Cloudflare adapter

- [#&#8203;16562](withastro/astro#16562) [`07529ec`](withastro/astro@07529ec) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fixes non-prerendered routes failing when a dynamic prerendered route exists in the same project with `prerenderEnvironment: 'node'`

- [#&#8203;16638](withastro/astro#16638) [`272185b`](withastro/astro@272185b) Thanks [@&#8203;ematipico](https://github.com/ematipico)! - Fixes a bug where the Astro compiler wasn't freed at the end of the build. After the fix, the memory used by the compiler is now correctly freed at the end of the build.

- [#&#8203;16544](withastro/astro#16544) [`d365c97`](withastro/astro@d365c97) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Tightens `isRemotePath()` to reject control characters after a leading slash and fixes the dev image endpoint origin check

- [#&#8203;16685](withastro/astro#16685) [`889e748`](withastro/astro@889e748) Thanks [@&#8203;farrosfr](https://github.com/farrosfr)! - Improve validation messages for `security.csp.directives` when `script-src` or `style-src` are incorrectly placed in the `directives` array.

- [#&#8203;16605](withastro/astro#16605) [`772f13a`](withastro/astro@772f13a) Thanks [@&#8203;rururux](https://github.com/rururux)! - Fixes `assetsPrefix` not being available on `build` from `astro:config/server`.

- [#&#8203;16556](withastro/astro#16556) [`f38dec7`](withastro/astro@f38dec7) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Rejects double-encoded URL paths with a 400 response instead of silently falling back to partial decoding

- [#&#8203;16659](withastro/astro#16659) [`38bcb25`](withastro/astro@38bcb25) Thanks [@&#8203;jsparkdev](https://github.com/jsparkdev)! - Fixes `&` characters appearing as raw entity strings (e.g. `&#&#8203;38;`) in `<meta>` tags when viewed in link previews or raw HTML.

- Updated dependencies \[[`d365c97`](withastro/astro@d365c97), [`9256345`](withastro/astro@9256345)]:
  - [@&#8203;astrojs/internal-helpers](https://github.com/astrojs/internal-helpers)@&#8203;0.9.1
  - [@&#8203;astrojs/markdown-remark](https://github.com/astrojs/markdown-remark)@&#8203;7.1.2

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNzAuMjAiLCJ1cGRhdGVkSW5WZXIiOiI0My4xNzAuMjAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants