Repository navigation
[access] refactor(files): split FileService validation, folder resolution and write into named steps - #1073
Open
rubenvdlinde wants to merge 2 commits into
Open
[access] refactor(files): split FileService validation, folder resolution and write into named steps#1073rubenvdlinde wants to merge 2 commits into
rubenvdlinde wants to merge 2 commits into
Conversation
Assisted-by: ClaudeCode:claude-opus-5-5
…write into named steps Assisted-by: ClaudeCode:claude-opus-5-5
rubenvdlinde
requested review from
WilcoLouwerse,
bbrands02 and
rjzondervan
as code owners
November 11, 2026 18:18
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.
What changed
FileService(the link-create file writer) reads as named steps:getAllowedExtensionsandsetAllowedExtensionsshare onenormaliseExtensions/normaliseExtensionpair instead of two copies of the same normalisation loop.assertValidFilenamechecks the length, thencontainsAnyfor the forbidden substrings, then the pattern; every refusal is the same exception as before.resolveTargetFolderkeeps the user-folder shortcut and hands subdirectories tofolderAt(existingFolder,createFolder) with the same three storage-failure messages.writeFile(signature unchanged) usesassertMayReplaceandoverwrite; the refuse-mode exception still passes through unwrapped and every other failure is still "Failed to write file".Allowed and refused outcomes are unchanged, and every check still runs before storage is touched, in the original order (filename, directory, extension, user folder, target folder, write).
Characterisation tests
tests/Unit/Service/FileServiceGuardGoldenTest.phpwas committed first, against the old code, and passes before and after. It pins the allowed writes (longest allowed name, root and nested directories, existing and created subfolders, replace mode) and the refused ones (each filename check, each directory check, filename-before-directory precedence, extension off the list, refuse mode) with no storage access on a refusal, every storage-failure message, and the allow-list normalisation on read and on save. Mutation check: disabling one filename check on the old code turned the golden red; restored before committing.What ran
vendor/bin/phpunit -c phpunit.xml --no-coverage tests/Unit: 2779 tests OK (13 skipped, as on development).vendor/bin/phpcsandvendor/bin/phpstan analyseonlib/Service/FileService.php: clean.Figures (touched file
lib/Service/FileService.php)createFile, untouched)App-wide: unit complexity 4.02 → 4.08, unit size 3.40 → 3.42, duplication 4.54 → 4.56.
Maintainability floor: compare against development holds.
AI-assisted: prepared with Claude Code (claude-opus-5-5); reviewed by a maintainer before merge.
Generated by Claude Code