From 60d5a2efeac4018b6709b406eed2ee64facfcadf Mon Sep 17 00:00:00 2001 From: MechaCat02 Date: Mon, 13 Jul 2026 21:56:19 +0200 Subject: [PATCH] docs: clarify that MAX_PAGES_PER_CHAPTER=0 relies on the body-size backstop Make explicit (config.rs + .env.example) that disabling the per-chapter page cap leaves MAX_REQUEST_BYTES as the sole bound (audit footgun). No behavior change; the thumbnail-source read is already bounded by MAX_FILE_BYTES + decode limits. Co-Authored-By: Claude Opus 4.8 --- .env.example | 6 ++++-- backend/src/config.rs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index 3747b61..3a76bc3 100644 --- a/.env.example +++ b/.env.example @@ -118,8 +118,10 @@ MAX_REQUEST_BYTES=209715200 MAX_FILE_BYTES=20971520 # Max page images accepted in one chapter upload. Bounds how many parts # the handler will stage before rejecting the request with 413, so a -# client can't pin a worker with an unbounded page count. 0 disables the -# cap. Default 2000. +# client can't pin a worker with an unbounded page count. Default 2000. +# Setting 0 disables THIS cap — the total is then bounded only by +# MAX_REQUEST_BYTES (the whole-request body limit above), so leave 0 only +# if you intend that body limit to be the sole backstop. MAX_PAGES_PER_CHAPTER=2000 # ----- Crawler download safety ----- diff --git a/backend/src/config.rs b/backend/src/config.rs index d9bcd9a..26c778d 100644 --- a/backend/src/config.rs +++ b/backend/src/config.rs @@ -66,8 +66,10 @@ pub struct UploadConfig { pub max_file_bytes: usize, /// Max page images accepted in one chapter upload. Bounds how many /// parts the handler will stage before giving up, so a client can't - /// pin a worker streaming an unbounded page count. `0` disables the - /// cap. Defaults to 2000. `MAX_PAGES_PER_CHAPTER`. + /// pin a worker streaming an unbounded page count. `0` disables THIS + /// cap — the total is then bounded only by `max_request_bytes` (the + /// whole-request body limit), which stays the backstop either way. + /// Defaults to 2000. `MAX_PAGES_PER_CHAPTER`. pub max_pages_per_chapter: usize, }