Skip to content

Allow files in public dir - #445

Open
freekh wants to merge 17 commits into
mainfrom
allow-files-in-public-dir
Open

Allow files in public dir#445
freekh wants to merge 17 commits into
mainfrom
allow-files-in-public-dir

Conversation

@freekh

@freekh freekh commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@freekh
freekh requested a review from Copilot June 24, 2026 15:47
@changeset-bot

changeset-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fd9ecb1

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

This PR includes changesets to release 7 packages
Name Type
@valbuild/core Patch
@valbuild/shared Patch
@valbuild/server Patch
@valbuild/cli Patch
@valbuild/ui Patch
@valbuild/next Patch
@valbuild/react Patch

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR broadens Val’s “managed files” location from the hard-coded /public/val subtree to any configurable /public (or /public/...) directory, updating UI, CLI, server validation/fix flows, and core remote-ref typing/parsing to match.

Changes:

  • Expand files.directory configuration support from /public/val to /public or /public/... (CLI + shared config parsing).
  • Update remote ref creation/parsing/validation to allow public/... paths instead of only public/val/....
  • Adjust UI utilities and components to derive display names/paths correctly with the new directory rules.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/ui/spa/utils/getFilenameFromRef.ts Updates folder derivation to strip /public rather than /public/val.
packages/ui/spa/search/search.worker.ts Updates file/image search indexing label extraction for new directory scheme.
packages/ui/spa/components/fields/ModuleGallery.tsx Updates remote filePath typing to accept public/... paths.
packages/ui/spa/components/fields/FileField.tsx Updates remote filePath typing to accept public/... paths.
packages/shared/src/internal/SharedValConfig.ts Expands config schema validation for files.directory.
packages/shared/src/internal/richtext/conversion/remirrorToRichTextSource.ts Updates remote filePath typing for richtext image uploads.
packages/server/src/createFixPatch.ts Broadens server-side remote download validation from public/val/ to public/.
packages/server/src/checkRemoteRef.ts Broadens remote-ref filePath validation and fix-path typing to public/....
packages/core/src/source/remote.ts Updates RemoteRef template + createRemoteRef typing to accept public/....
packages/core/src/schema/images.ts Makes images() options/accept optional; defaults accept to image/*.
packages/core/src/remote/splitRemoteRef.ts Broadens splitRemoteRef parsing typing/validation to public/....
packages/core/src/initVal.ts Expands ConfigDirectory type to /public or /public/....
packages/cli/src/utils/evalValConfigFile.ts Updates CLI config validation to accept /public or /public/....
packages/cli/src/runValidation.ts Broadens CLI remote upload directory enforcement to public/....
packages/cli/src/listUnusedFiles.ts Uses evaluated val.config.* to determine the managed directory instead of assuming public/val.
packages/cli/src/cli.ts Updates CLI help text for list-unused-files to reflect configurable directory.
Comments suppressed due to low confidence (1)

packages/core/src/remote/splitRemoteRef.ts:37

  • splitRemoteRef only checks that filePath starts with public/, but it does not reject path traversal segments like public/../.... Downstream code (e.g. server-side download to path.join(projectRoot, filePath)) can be tricked into writing outside the intended directory. Reject ./.. segments in the parsed filePath.
  if (match[7].indexOf("public/") !== 0) {
    return {
      status: "error",
      error: "Invalid remote ref: " + ref,
    };
  }

Comment thread packages/ui/spa/utils/getFilenameFromRef.ts Outdated
Comment thread packages/ui/spa/search/search.worker.ts Outdated
Comment thread packages/ui/spa/components/fields/ModuleGallery.tsx Outdated
Comment thread packages/ui/spa/components/fields/FileField.tsx Outdated
Comment thread packages/shared/src/internal/SharedValConfig.ts Outdated
Comment thread packages/cli/src/utils/evalValConfigFile.ts Outdated
freekh and others added 6 commits June 24, 2026 20:24
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.

Comment thread packages/core/src/source/remote.ts
Comment thread packages/cli/src/utils/evalValConfigFile.ts Outdated
Comment thread packages/core/src/schema/images.ts
Comment thread packages/core/src/schema/images.ts
freekh and others added 8 commits July 28, 2026 09:33
The RemoteRef template literal was missing the `/b/{bucket}` segment that
createRemoteRef writes and splitRemoteRef parses, so the "project id"
segment could silently absorb `/b/...`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…teRef

Covers the broadened `public/...` file paths and the `.`/`..` segment
rejection, including that dots inside a file name are not traversal.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Aligns files.directory validation with the remote-ref checks so the
directory cannot escape /public via `.` or `..` segments.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
accept is now optional and defaults to "image/*" - document that on the
option and on s.images() itself, and add tests for the accept, directory,
alt and remote defaults when options are omitted.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
/^\/public/ also matched refs like "/publicity/a.png", mangling the
displayed folder. Anchor on a segment boundary and add tests for
getFilenameFromRef/getRefParts, which had none.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Since the config.files.directory fallback was removed, imageDirectory was
just an alias for imageModuleDirectory.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The PR changes packages/ui/spa, but @valbuild/ui only has @valbuild/core
and @valbuild/shared as devDependencies, so changesets would not bump it
via the dependency graph and the studio changes would ship unversioned.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants