mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6101] [MERGED] fix(sub): omit hyphen for empty remark variables #6080
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#6080
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/6101
Author: @Tosd0
Created: 7/25/2026
Status: ✅ Merged
Merged: 7/28/2026
Merged by: @MHSanaei
Base:
main← Head:fix/empty-inbound-remark-separator📝 Commits (3)
d1f2f13fix(sub): omit hyphen for empty remark variables57eac2ffix(sub): elide the remark separator after leading decoration2aed5f6Merge branch 'main' into fix/empty-inbound-remark-separator📊 Changes
2 files changed (+109 additions, -21 deletions)
View changed files
📝
internal/sub/remark_vars.go(+74 -21)📝
internal/sub/remark_vars_test.go(+35 -0)📄 Description
Summary
-between two adjacent remark variables as their separator and drop it when no variable before it has produced a value yet, or when the value after it is empty.Root cause
b0c1156dmade display remarks template-driven, with{{INBOUND}}-{{EMAIL}}|📊{{TRAFFIC_LEFT}}|⏳{{DAYS_LEFT}}Das the default template.-in place.-john@example.comin subscription clients.expandSegmentnow walks the variable matches instead of doing a blindReplaceAllStringFunc, so it can see the text between two matches and judge whether that text is a separator an empty value left dangling. Segment-drop behavior for unlimited quota/expiry is unchanged.Commits
omit hyphen for empty remark variables— the regression fix, covering the shipped default template.elide the remark separator after leading decoration— extends the same rule to templates that open with decoration, so🌐{{INBOUND}}-{{EMAIL}}renders🌐johninstead of🌐-johnfor an inbound with no remark. Kept separate; drop it if you would rather hold this PR to the regression alone.Scope
Only a lone
-between two variables counts as a separator, which covers the default template. Other separators a user may have typed ({{INBOUND}} {{EMAIL}},{{INBOUND}}_{{EMAIL}}) still keep their leading character when the first variable is empty; widening the set changes behavior for existing templates, so it is left out of this regression fix — glad to extend it here if you would rather cover them in one go. Paired decoration such as{{EMAIL}} ({{INBOUND}})is deliberately untouched, since dropping one side would leave a dangling bracket.Test plan
go test ./internal/sub -count=1go vet ./internal/sub,gofmt -l internal/subclean,go build ./...#emptyremarkin its subscription, the one remarkedGermanystill serves#Germany-hasremarkTestExpandRemarkVars_DropsHyphenBetweenEmptyTokenscovers both values present, empty inbound, empty email, a literal leading hyphen, an empty variable between two values, leading decoration, and the shipped default template end to end. The empty cases fail onmain.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.