[PR #6183] [MERGED] fix(sub): serve a copy-only page when a subscription URL is opened in a browser #6145

Closed
opened 2026-11-02 04:06:40 +07:00 by bsakaguchi · 0 comments
Owner

📋 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)

  • 5b4d4cc fix(sub): show copy-only page for browser subscription visits
  • 8021492 fix(sub): keep the themed page for an explicit html request
  • b1acb33 fix(sub): keep browser pages copy-only
  • a16af9d Merge 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 Accept header.

Why

maybeServeSubPage renders 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 Accept header 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=1 and ?view=html only, so a browser navigation that did not advertise HTML fell through to the raw subscription body.

Scope

  • maybeServeSubPage still validates the subscription, but renders serveSubscriptionCopyPage — a page that lets the user copy the subscription URL without embedding the config payload.
  • New isBrowserSubscriptionRequest adds two further signals:
    • Sec-Fetch-Dest: document / Sec-Fetch-Mode: navigate, which browsers send on real navigations regardless of Accept.
    • a Mozilla/ User-Agent check, with an explicit allowlist for VPN clients that also send a Mozilla/ prefix (clash, mihomo, sing-box, v2ray, xray, hiddify, nekobox, shadowrocket, streisand, v2box and others) so importing clients keep receiving the raw body.
  • No change to what a subscription client receives.

Validation

  • go build ./internal/... clean.
  • go test ./internal/sub/ green on main at ece16559 with this applied, including the new browser-detection cases.
  • Cherry-picks onto current main without 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.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6183 **Author:** [@n0ctal](https://github.com/n0ctal) **Created:** 8/8/2026 **Status:** ✅ Merged **Merged:** 8/15/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `upstream-browser-subscription-copy-page` --- ### 📝 Commits (4) - [`5b4d4cc`](https://github.com/MHSanaei/3x-ui/commit/5b4d4ccf2573956264cd7ab4828855323b91bc93) fix(sub): show copy-only page for browser subscription visits - [`8021492`](https://github.com/MHSanaei/3x-ui/commit/802149296f9239d6e6c2844dceea09198ce125cd) fix(sub): keep the themed page for an explicit html request - [`b1acb33`](https://github.com/MHSanaei/3x-ui/commit/b1acb339c4c82b1a764f34ecafb4817a54859d0b) fix(sub): keep browser pages copy-only - [`a16af9d`](https://github.com/MHSanaei/3x-ui/commit/a16af9db2391412701e86ab54f5a6c779f08b56b) Merge branch 'main' into upstream-browser-subscription-copy-page ### 📊 Changes **16 files changed** (+312 additions, -96 deletions) <details> <summary>View changed files</summary> 📝 `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) </details> ### 📄 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 `Accept` header. ## Why `maybeServeSubPage` renders 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 `Accept` header 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=1` and `?view=html` only, so a browser navigation that did not advertise HTML fell through to the raw subscription body. ## Scope - `maybeServeSubPage` still validates the subscription, but renders `serveSubscriptionCopyPage` — a page that lets the user copy the subscription URL without embedding the config payload. - New `isBrowserSubscriptionRequest` adds two further signals: - `Sec-Fetch-Dest: document` / `Sec-Fetch-Mode: navigate`, which browsers send on real navigations regardless of `Accept`. - a `Mozilla/` User-Agent check, with an explicit allowlist for VPN clients that also send a `Mozilla/` prefix (clash, mihomo, sing-box, v2ray, xray, hiddify, nekobox, shadowrocket, streisand, v2box and others) so importing clients keep receiving the raw body. - No change to what a subscription client receives. ## Validation - `go build ./internal/...` clean. - `go test ./internal/sub/` green on `main` at `ece16559` with this applied, including the new browser-detection cases. - Cherry-picks onto current `main` without 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:06:40 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6145
No description provided.