Skip to content

Commit

Permalink
fix(remix-dev/vite): validate server bundle IDs (#8598)
Browse files Browse the repository at this point in the history
  • Loading branch information
markdalgleish authored Jan 25, 2024
1 parent 2f05fd2 commit 6ec38fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-dingos-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/dev": patch
---

Vite: Validate IDs returned from the `serverBundles` function to ensure they only contain alphanumeric characters, hyphens and underscores
5 changes: 5 additions & 0 deletions packages/remix-dev/vite/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ async function getServerBuilds(ctx: RemixPluginContext): Promise<{
if (typeof serverBundleId !== "string") {
throw new Error(`The "serverBundles" function must return a string`);
}
if (!/^[a-zA-Z0-9-_]+$/.test(serverBundleId)) {
throw new Error(
`The "serverBundles" function must only return strings containing alphanumeric characters, hyphens and underscores.`
);
}
buildManifest.routeIdToServerBundleId[route.id] = serverBundleId;

let relativeServerBundleDirectory = path.relative(
Expand Down

0 comments on commit 6ec38fa

Please sign in to comment.