mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6183] [MERGED] fix(sub): serve a copy-only page when a subscription URL is opened in a browser #6145
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#6145
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/6183
Author: @n0ctal
Created: 8/8/2026
Status: ✅ Merged
Merged: 8/15/2026
Merged by: @MHSanaei
Base:
main← Head:upstream-browser-subscription-copy-page📝 Commits (4)
5b4d4ccfix(sub): show copy-only page for browser subscription visits8021492fix(sub): keep the themed page for an explicit html requestb1acb33fix(sub): keep browser pages copy-onlya16af9dMerge branch 'main' into upstream-browser-subscription-copy-page📊 Changes
16 files changed (+312 additions, -96 deletions)
View changed files
📝
internal/sub/controller.go(+100 -79)➕
internal/sub/controller_browser_test.go(+133 -0)📝
internal/sub/info_endpoint_test.go(+27 -4)📝
internal/web/translation/ar-EG.json(+4 -1)📝
internal/web/translation/en-US.json(+4 -1)📝
internal/web/translation/es-ES.json(+4 -1)📝
internal/web/translation/fa-IR.json(+4 -1)📝
internal/web/translation/id-ID.json(+4 -1)📝
internal/web/translation/ja-JP.json(+4 -1)📝
internal/web/translation/pt-BR.json(+4 -1)📝
internal/web/translation/ru-RU.json(+4 -1)📝
internal/web/translation/tr-TR.json(+4 -1)📝
internal/web/translation/uk-UA.json(+4 -1)📝
internal/web/translation/vi-VN.json(+4 -1)📝
internal/web/translation/zh-CN.json(+4 -1)📝
internal/web/translation/zh-TW.json(+4 -1)📄 Description
Summary
Serve a copy-only page, instead of the full subscription page, when a subscription URL is opened by a browser, and widen browser detection beyond the
Acceptheader.Why
maybeServeSubPagerenders the normal subscription page for any request that looks like a browser. That page embeds the share links in its page data — the actual configs, inline in the HTML.Subscription URLs travel. They get pasted into chats, forwarded to a second device, opened to "check if it still works". Anything that fetches the URL with an HTML-ish
Acceptheader renders the page and receives every config on it: a messenger unfurling a link preview, a corporate proxy prefetching, a browser extension, a shared-screen moment. None of that requires the recipient to intend anything — the configs are simply in the response body.Detection was also narrower than the traffic it has to classify. It keyed on
Accept: text/html,?html=1and?view=htmlonly, so a browser navigation that did not advertise HTML fell through to the raw subscription body.Scope
maybeServeSubPagestill validates the subscription, but rendersserveSubscriptionCopyPage— a page that lets the user copy the subscription URL without embedding the config payload.isBrowserSubscriptionRequestadds two further signals:Sec-Fetch-Dest: document/Sec-Fetch-Mode: navigate, which browsers send on real navigations regardless ofAccept.Mozilla/User-Agent check, with an explicit allowlist for VPN clients that also send aMozilla/prefix (clash, mihomo, sing-box, v2ray, xray, hiddify, nekobox, shadowrocket, streisand, v2box and others) so importing clients keep receiving the raw body.Validation
go build ./internal/...clean.go test ./internal/sub/green onmainatece16559with this applied, including the new browser-detection cases.mainwithout conflict.Risk
Low for clients, moderate for anyone who relied on the browser page to read configs directly — that is the behaviour being removed on purpose. The client allowlist is the one place to review: a client not on it that sends
Mozilla/and does not identify itself would now get the copy page instead of the body. Happy to extend the list with any client you know of.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.