Repository navigation
Fix request validation bugs and consolidate duplicated route code - #8
Merged
Merged
Conversation
Bugs: - Sanitize uploaded cookie filenames; a name like ../../../x was joined onto the cookies folder as-is and could write outside it. - Skip media ids that no longer exist when adding to a board, instead of failing the foreign key and 500ing the whole add. - Validate every key in a settings PATCH before writing any, so a rejected request no longer applies the keys ahead of the bad one. - Escape _ and % in tag search so they match literally; _ is in most tag names and was acting as a single-character wildcard. Performance: - Scans skip the existence check for files the walk just found, instead of statting every indexed file a second time. - Size the thumbnail folder asynchronously so /api/system no longer blocks the server on large libraries. - Stop rebuilding the downloader log list on every render. Cleanup: - Share one MEDIA_SELECT query and a typed MediaSqlRow in place of six copies and `any` rows. - Share multipart parsing, filename sanitizing and SSE setup helpers. - attachFolder reports whether it created the folder, so the folder route no longer checks for duplicates twice. - Correct the editable settings list in docs/API.md.
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.
Bug fixes
Each one has a regression test in
apps/server/src/requestValidation.test.tsthat fails onmasterand passes here.DOWNLOADER_COOKIES_DIRas-is, so a name like../../../xescaped it. It's now cleaned with the samesanitizeFilenamethat media uploads already used.board_media → mediaforeign key and nothing was added. Ids are now selected frommedia, so missing ones are skipped. Remove-from-board now deletes ids in chunks instead of one at a time.400. All keys are now checked before any write._as a wildcard._appears in most tag names, solong_halso matchedlongxhair._,%and\are now escaped (LIKE … ESCAPE '\').Performance
pruneMissingskips files the walk just found. Before, a rescan of an unchanged library checked every indexed file on disk a second time. This only ever skips checks, so it can't cause a wrong prune. One trade-off: a file deleted while indexing is still running is now pruned on the next scan instead of the current one./api/systemno longer blocks the server. The thumbnail folder was sized with synchronousstatcalls, one per media item. It's now async.DownloaderPagebuilt a new[]on every render, which defeated itsuseMemo. Fixed.Cleanup
MEDIA_SELECTplus a typedMediaSqlRowreplace six copies of the media query androwToMedia(row: any). Lint warnings go from 61 to 33.readFormData,formFilesandopenEventStreaminlib/http.ts.attachFoldernow reports whether it created the folder, soPOST /api/libraries/:id/foldersno longer checks for duplicates twice.docs/API.md: the editable settings list included a key that doesn't exist (autosearch_first_tag) and was missingvideo_transcode_enabledanddiscover_enabled.Verification
bun install --frozen-lockfile,bun run lint,bun run typecheck,bun test --isolate(126 pass, run 3×) andbun run buildall pass locally..txtupload is rejected, and a cover image saves.