Skip to content

Separate the content hash in uploaded filenames - #382

Merged
PercolatingStudio merged 1 commit into
mainfrom
codex/issue-356-upload-filename
Nov 19, 2026
Merged

PercolatingStudio merged 1 commit into
mainfrom
codex/issue-356-upload-filename

Conversation

@PercolatingStudio

Copy link
Copy Markdown
Owner

Fixes #356.

Reproduction

On the published 3.2.5 ZIP with PrestaShop 9.1.4, upload my-image-1200.png through the authenticated PrettyBlocks file upload endpoint. The stored and returned name is my-image-1200<md5>.png: PrestaShop's URL sanitizer removes the underscore before the hash.

Change

Sanitize the original stem first, then append a hyphen, the full content hash, and the extension. Truncate only the stem to fit 255 bytes without cutting a UTF-8 character or losing the hash. This keeps distinct uploads from sharing a filename even when the original name is long. Existing uploads and stored URLs are not renamed or migrated.

Thanks to @Daaaaad for the detailed report.

Validation

  • A real-upload regression assertion fails on the published ZIP and passes on the corrected ZIP. Added a filename regression fixture to the local release smoke suite.
  • Built the candidate with the normal builder (SHA-256 30806d5292e2ed825ecfa21bfc739524e5f0b753d0396fec3789d322b382cd8d) and installed that exact ZIP on PS 8.2.7/PHP 8.1.33 and PS 9.1.4/PHP 8.5.0. Manifest, assets and smoke tests pass on both.
  • Real authenticated uploads on both shops: verify the returned filename and served bytes, identical re-upload returns the same URL, distinct contents with the same original name use distinct files, long names keep all 32 hash characters, and a custom upload path still works.
  • Replaced the package in the existing disposable PS9.1 shop via the native ZIP handler. The previously uploaded no-hyphen file retained its exact checksum and remained accessible at its original URL.
  • All 40 Node tests, PHP/shell syntax, and git diff --check pass. No merge conflicts found with Disable sorting on PrettyBlocks action columns #380 or Prevent stale saves from restoring deleted repeater items #381 in the local merge simulations.

No version bump, schema change, or release.

@PercolatingStudio
PercolatingStudio merged commit d434a53 into main Nov 19, 2026
3 checks passed
@PercolatingStudio
PercolatingStudio deleted the codex/issue-356-upload-filename branch November 19, 2026 12:42
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.

Uploaded file names: hash glued to the original name (underscore separator stripped by str2url)

1 participant