[PR #6977] [MERGED] fix(link): decode share link remarks once #6559

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6977
Author: @jayhemnani9910
Created: 10/27/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @MHSanaei

Base: main ← Head: fix/link-remark-decode


📝 Commits (1)

  • 2ce8477 fix(link): decode share link remarks once

📊 Changes

2 files changed (+35 additions, -4 deletions)

View changed files

📝 internal/util/link/outbound.go (+4 -4)
📝 internal/util/link/outbound_helpers_test.go (+31 -0)

📄 Description

Summary

Remarks of imported vless, trojan, hysteria2 and wireguard links are percent-decoded once instead of twice, so + and % in a remark survive.

Why

url.Parse already decodes the fragment into u.Fragment, and decodeHash then decoded it again with url.QueryUnescape. The subscription server writes remarks with encodeURIComponent (internal/sub/service.go), so a remark comes back changed when one 3x-ui panel imports another's subscription:

Remark Fragment in the link Imported tag before
VIP+ VIP%2B VIP
US+EU 1 US%2BEU%201 US EU 1
a%20b a%2520b a b

The shadowsocks parser decodes the raw fragment once and returns the right remark for the same input.

The fix passes decodeHash the escaped fragment (u.EscapedFragment()), so these links decode it once, as shadowsocks links do.

Type of change

  • Bug fix

Areas affected

  • Subscription (share links / Clash / JSON)

How was this tested?

  • New test TestParse_RemarkDecodedOnce in internal/util/link/outbound_helpers_test.go parses those fragments, plus a Cyrillic one, for vless, trojan, hysteria2, wireguard and shadowsocks links. On main it fails 12 times (three remarks across the four URL-form protocols); with the change it passes.
  • go test -shuffle=on -count=1 ./... passes (52 packages). golangci-lint run ./internal/util/link/ reports 0 issues.

Breaking changes

None.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 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/6977 **Author:** [@jayhemnani9910](https://github.com/jayhemnani9910) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/link-remark-decode` --- ### 📝 Commits (1) - [`2ce8477`](https://github.com/MHSanaei/3x-ui/commit/2ce8477149d282d70a5f99a7b7e3607cc3006632) fix(link): decode share link remarks once ### 📊 Changes **2 files changed** (+35 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `internal/util/link/outbound.go` (+4 -4) 📝 `internal/util/link/outbound_helpers_test.go` (+31 -0) </details> ### 📄 Description ## Summary Remarks of imported vless, trojan, hysteria2 and wireguard links are percent-decoded once instead of twice, so `+` and `%` in a remark survive. ## Why `url.Parse` already decodes the fragment into `u.Fragment`, and `decodeHash` then decoded it again with `url.QueryUnescape`. The subscription server writes remarks with `encodeURIComponent` (`internal/sub/service.go`), so a remark comes back changed when one 3x-ui panel imports another's subscription: | Remark | Fragment in the link | Imported tag before | |---|---|---| | `VIP+` | `VIP%2B` | `VIP ` | | `US+EU 1` | `US%2BEU%201` | `US EU 1` | | `a%20b` | `a%2520b` | `a b` | The shadowsocks parser decodes the raw fragment once and returns the right remark for the same input. The fix passes `decodeHash` the escaped fragment (`u.EscapedFragment()`), so these links decode it once, as shadowsocks links do. ## Type of change - [x] Bug fix ## Areas affected - [x] Subscription (share links / Clash / JSON) ## How was this tested? - New test `TestParse_RemarkDecodedOnce` in `internal/util/link/outbound_helpers_test.go` parses those fragments, plus a Cyrillic one, for vless, trojan, hysteria2, wireguard and shadowsocks links. On main it fails 12 times (three remarks across the four URL-form protocols); with the change it passes. - `go test -shuffle=on -count=1 ./...` passes (52 packages). `golangci-lint run ./internal/util/link/` reports 0 issues. ## Breaking changes None. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [ ] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi changed title from [PR #6977] fix(link): decode share link remarks once to [PR #6977] [MERGED] fix(link): decode share link remarks once 2026-11-07 14:33:58 +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#6559
No description provided.