Stop a saved Rule from taking uploads it does not own #120

Merged
an.di merged 2 commits from adilallo/fix/CR-467-upload-ownership into main 2026-11-25 03:37:57 +00:00
Member

Overview

Saving a Rule used to move every upload its document named onto that Rule, including files that already belonged to another Rule or another account. Duplicating, saving the copy, then deleting the copy could 404 the original’s logo. Naming another Rule’s path in your own document could take the file.

A save now links only unlinked uploads made by this account or browser. Duplicate and Make a copy write their own copies of files they keep, and roll the new Rule back if those copies cannot be saved.

Changes

  • linkUploadsToRule / linkUploadsToDraft skip files linked elsewhere or owned by someone else; guest files still attach when this browser holds the upload grant
  • Duplicate and Make a copy copy owned files onto the new Rule and rewrite /api/uploads/… paths (Make a copy still drops the photo)
  • If that copy-and-rewrite cannot be saved, the new Rule is deleted instead of sharing the original’s files
  • Unit coverage for steal cases, path rewrite, file copy, Duplicate, and Make a copy

Screenshots

original-logo-still-200.png

How to Test

  1. Sign in, publish a Rule with a logo, Duplicate it from Profile.
  2. Open the copy, save it with the document unchanged, then delete the copy.
  3. Open the original. Its logo should still load (not 404).
  4. As a second account, publish a Rule whose text only names the first Rule’s /api/uploads/… path. The second account should not be able to read or delete that file.
  5. Duplicate and Make a copy should each get their own copies of any file they keep (Make a copy still has no photo).

Notes

  • Readers of a file still follow the linked Rule, as before.
  • Existing rows that already stole a file are not repaired here; only new saves and copies are gated.original-rule-after-copy-deleted.png
## Overview Saving a Rule used to move every upload its document named onto that Rule, including files that already belonged to another Rule or another account. Duplicating, saving the copy, then deleting the copy could 404 the original’s logo. Naming another Rule’s path in your own document could take the file. A save now links only unlinked uploads made by this account or browser. Duplicate and Make a copy write their own copies of files they keep, and roll the new Rule back if those copies cannot be saved. ## Changes - `linkUploadsToRule` / `linkUploadsToDraft` skip files linked elsewhere or owned by someone else; guest files still attach when this browser holds the upload grant - Duplicate and Make a copy copy owned files onto the new Rule and rewrite `/api/uploads/…` paths (Make a copy still drops the photo) - If that copy-and-rewrite cannot be saved, the new Rule is deleted instead of sharing the original’s files - Unit coverage for steal cases, path rewrite, file copy, Duplicate, and Make a copy ## Screenshots ![original-logo-still-200.png](attachments/94fd17f4-373c-4d90-899f-722fdc220b86) ## How to Test 1. Sign in, publish a Rule with a logo, Duplicate it from Profile. 2. Open the copy, save it with the document unchanged, then delete the copy. 3. Open the original. Its logo should still load (not 404). 4. As a second account, publish a Rule whose text only names the first Rule’s `/api/uploads/…` path. The second account should not be able to read or delete that file. 5. Duplicate and Make a copy should each get their own copies of any file they keep (Make a copy still has no photo). ## Notes - Readers of a file still follow the linked Rule, as before. - Existing rows that already stole a file are not repaired here; only new saves and copies are gated.![original-rule-after-copy-deleted.png](attachments/47557e54-8f09-408b-be02-1bbc883c11a9)
an.di added 2 commits 2026-11-25 03:37:25 +00:00
A named path no longer moves another Rules file. Duplicate and Make a copy write their own copies of files they keep.
an.di merged commit 53e27ef122 into main 2026-11-25 03:37:57 +00:00
an.di deleted branch adilallo/fix/CR-467-upload-ownership 2026-11-25 03:37:57 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: CommunityRule/community-rule#120