Repository navigation
fix(accessories): reject nested resource entries - #2050
Merged
Merged
Conversation
Changing an accessory's resources with only nested entries in the resource list (resource[][]=x) removed every resource from the accessory. When the list also held valid entries, those were saved and the nested ones were ignored. Since 978565a the page read the list with GetFormStringList(), which drops entries that are not strings. A list holding only a nested entry reached the presenter as an empty list, which means "no resources selected". The check added in ccc443a, which rejects the request when an entry is not a string, could no longer run. GetAccessoryResources() now returns the list as submitted, so the presenter sees the nested entry and changes nothing. A single value is still read as a one-item list, and a missing or blank field as an empty list. Real-world severity is low: - The form never submits a nested entry. The request has to be built by hand. - Only an application administrator can send it, and it needs that administrator's CSRF token. - The same administrator can get the same result from the form by unticking every resource, so it grants nothing new. - The effect is limited to one accessory: its resource links and their minimum and maximum quantities are deleted and have to be entered again. No reservations are changed. The presenter tests mock the page and kept passing. Add tests that drive the presenter through the real page. Assisted-by: Claude:claude-fable-5-2
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain, and the changes include page-level coverage for malformed submissions, valid updates, and intentional clearing behavior.
No open issues 🎉
What changed in this PR
This PR prevents malformed nested accessory-resource submissions from being interpreted as an intentional empty selection that deletes all existing resource links.
Changes:
- Preserve submitted resource values, including nested entries, so presenter validation can reject malformed requests.
- Add page-level tests for malformed resources and quantities, valid updates, and intentional empty selections.
| File | Description |
|---|---|
| tests/Pages/Admin/ManageAccessoriesPageTest.php | Adds real-page coverage for malformed submissions, valid resource updates, malformed quantities, and clearing all selections. |
| Pages/Admin/ManageAccessoriesPage.php | Preserves submitted accessory-resource entries so nested values reach presenter validation instead of being filtered into an empty list. |
Review effort: Lite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changing an accessory's resources with only nested entries in the resource list (resource[][]=x) removed every resource from the accessory. When the list also held valid entries, those were saved and the nested ones were ignored.
Since 978565a the page read the list with GetFormStringList(), which drops entries that are not strings. A list holding only a nested entry reached the presenter as an empty list, which means "no resources selected". The check added in ccc443a, which rejects the request when an entry is not a string, could no longer run.
GetAccessoryResources() now returns the list as submitted, so the presenter sees the nested entry and changes nothing. A single value is still read as a one-item list, and a missing or blank field as an empty list.
Real-world severity is low:
The presenter tests mock the page and kept passing. Add tests that drive the presenter through the real page.
Assisted-by: Claude:claude-fable-5-2