fix(link): accept padded URL-safe base64 in vmess links (#6975)

parseVmess tried standard base64, then unpadded URL-safe base64, so a URL-safe body that kept its = padding failed both and the server silently dropped out of an imported outbound subscription. It now uses base64DecodeFlexible, the helper the shadowsocks parser already uses.
This commit is contained in:
Jay Hemnani
2026-11-02 19:40:13 +05:30
committed by GitHub
parent 1bdb517b88
commit 14f2bb5e2c
2 changed files with 30 additions and 7 deletions
+3 -7
View File
@@ -208,17 +208,13 @@ func dropHostLocalKeys(v any) {
func parseVmess(link string) (*ParseResult, error) {
b64 := strings.TrimPrefix(link, "vmess://")
// vmess:// base64(json)
raw, err := base64.StdEncoding.DecodeString(padBase64(b64))
if err != nil {
// Some providers use raw URL-safe
raw, err = base64.RawURLEncoding.DecodeString(b64)
}
// vmess:// base64(json), standard or URL-safe, padded or not
raw, err := base64DecodeFlexible(b64)
if err != nil {
return nil, fmt.Errorf("vmess decode: %w", err)
}
var j map[string]any
if err := json.Unmarshal(raw, &j); err != nil {
if err := json.Unmarshal([]byte(raw), &j); err != nil {
return nil, fmt.Errorf("vmess json: %w", err)
}