mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-17 10:35:02 +03:00
fix(sub): use a fullwidth percent in USAGE_PERCENTAGE (#6174)
* fix(sub): use a fullwidth percent in USAGE_PERCENTAGE A remark is placed in the share link fragment, so an ASCII percent is percent-encoded to %25. Happ treats such a fragment as malformed, discards the whole remark and falls back to showing the server hostname, which defeats the point of a remark template and leaks the host into the client's server list. Emit U+FF05 FULLWIDTH PERCENT SIGN instead. It renders the same to a reader, never produces %25, and round-trips through url.Parse unchanged. * test(sub): exercise production fragment encoding --------- Co-authored-by: n0ctal <293235942+n0ctal@users.noreply.github.com>
This commit is contained in:
@@ -350,8 +350,8 @@ func statusEmoji(st xray.ClientTraffic) string {
|
||||
}
|
||||
}
|
||||
|
||||
// usagePercentage computes the traffic usage as a percentage string (e.g. "52.3%").
|
||||
// Returns "" when the client has no traffic limit.
|
||||
// usagePercentage computes the traffic usage as a percentage string (e.g. "52.3%").
|
||||
// Uses U+FF05: an ASCII percent encodes to %25, which Happ rejects, dropping the remark.
|
||||
func usagePercentage(st xray.ClientTraffic) string {
|
||||
if st.Total <= 0 {
|
||||
return ""
|
||||
@@ -361,7 +361,7 @@ func usagePercentage(st xray.ClientTraffic) string {
|
||||
if pct > 100 {
|
||||
pct = 100 // clamp over-quota usage, consistent with TRAFFIC_LEFT
|
||||
}
|
||||
return fmt.Sprintf("%.1f%%", pct)
|
||||
return fmt.Sprintf("%.1f%", pct)
|
||||
}
|
||||
|
||||
// timeLeftLabel renders remaining time as "Xd Xh Xm" (or shorter when days/hours
|
||||
|
||||
Reference in New Issue
Block a user