fix(fmt): keep a ':' in a Naive password through export and import (#10526)

NaiveFmt.ToUri percent-encodes the username and password, so a
password-only profile with the password a:b is exported as
naive+https://a%3Ab@host. Resolve decoded the user info before
looking for the ':' separator and imported it as username "a",
password "b". Split the raw user info first and decode each part.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Wei-Lun Li
2026-11-05 12:13:47 +00:00
committed by GitHub
parent 7c49b236a0
commit 2010477f38
2 changed files with 76 additions and 4 deletions
+5 -4
View File
@@ -30,16 +30,17 @@ public class NaiveFmt : BaseFmt
NaiveQuic = true,
};
}
var rawUserInfo = Utils.UrlDecode(parsedUrl.UserInfo);
// Split before decoding: ToUri percent-encodes a ':' inside the username or password.
var rawUserInfo = parsedUrl.UserInfo;
if (rawUserInfo.Contains(':'))
{
var split = rawUserInfo.Split(':', 2);
item.Username = split[0];
item.Password = split[1];
item.Username = Utils.UrlDecode(split[0]);
item.Password = Utils.UrlDecode(split[1]);
}
else
{
item.Password = rawUserInfo;
item.Password = Utils.UrlDecode(rawUserInfo);
}
var query = Utils.ParseQueryString(parsedUrl.Query);