mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #5609] [MERGED] fix(web): don't let an empty skip-suffix disable the request body cap #5926
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#5926
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/5609
Author: @n0ctal
Created: 6/27/2026
Status: ✅ Merged
Merged: 6/28/2026
Merged by: @MHSanaei
Base:
main← Head:pr-bodylimit-empty-suffix📝 Commits (4)
1058c90fix(web): tighten database restore body-cap exemption6ae3dabMerge branch 'main' into pr-bodylimit-empty-suffixeaef727Merge branch 'main' into pr-bodylimit-empty-suffix3535d26Merge branch 'main' into pr-bodylimit-empty-suffix📊 Changes
3 files changed (+19 additions, -18 deletions)
View changed files
📝
internal/web/middleware/bodylimit.go(+4 -5)📝
internal/web/middleware/bodylimit_test.go(+12 -10)📝
internal/web/web.go(+3 -3)📄 Description
Summary
MaxBodyBytes(limit, skipSuffixes...)exempts a request when its path ends in one ofskipSuffixes. An empty string in that list makesstrings.HasSuffix(path, "")always true, so a single empty suffix silently disables the body-size cap for every route. This adds asuffix != ""guard and tightens the matcher (hasAnySuffix).Why
The body cap protects state-changing routes from unbounded request bodies (memory/DoS). An accidental empty entry in the skip list (e.g. from a config/format slip) removes that protection globally and silently.
Scope
internal/web/middleware/bodylimit.go: skip a path only when a non-empty configured suffix matches.internal/web/middleware/bodylimit_test.go: assert a sub-path of an exempt route (/importDB/other) is not exempt and that over-limit bodies on non-exempt paths are still capped.internal/web/web.go: minor call-site cleanup.Validation
go test ./internal/web/middlewarepasses (incl. the new sub-path/empty-suffix cases).Risk
Minimal. Exempt routes still work; only the unintended global bypass is closed.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.