fix(fmt): import legacy base64 SOCKS links again (#10505)

SocksFmt.Resolve tries ResolveSocksNew first and only falls back to the
legacy socks://base64(user:pass@host:port) parser when System.Uri
rejects the link. System.Uri accepts most legacy links, though: it takes
the base64 as the host (lower-cased) and anything after a '/' as the
path. It only rejects a base64 that ends in '=' padding and has no '/',
so links without padding, or with a '/' or '_' in the base64, were
imported with the base64 as the address, port -1 and no credentials.

A legacy link has no port of its own, so let ResolveSocksNew give up
when the URI has none and leave the link to ResolveSocks.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Wei-Lun Li
2026-11-03 17:00:48 +09:00
committed by GitHub
parent 0f1f82af4e
commit 522bca492c
2 changed files with 44 additions and 1 deletions
+4 -1
View File
@@ -86,7 +86,10 @@ public class SocksFmt : BaseFmt
private static ProfileItem? ResolveSocksNew(string result)
{
var parsedUrl = Utils.TryUri(result);
if (parsedUrl == null)
// A legacy socks://base64(user:pass@host:port) link has no port of its own, but System.Uri
// accepts many of them, reading the base64 as the host (and whatever follows a '/' as the
// path). Leave those to ResolveSocks.
if (parsedUrl == null || parsedUrl.Port == -1)
{
return null;
}