fix(uri): percent-encode the anytls password too

The anytls URI reuses the vless producer with the password as uuid, which
is written as is.
This commit is contained in:
Pharex38 committed 2026-10-24 18:59:15 +03:00
1 parent eda9781cc3
commit f9cfc754bc
2 files changed
+22 -1

No files matched your search

@@ -1468,7 +1468,8 @@ export default function URI_Producer() {
case 'anytls':
result = vless({
...proxy,
uuid: proxy.password,
// vless() writes the uuid as is; a password may contain @, :, # etc.
uuid: encodeURIComponent(proxy.password),
network: proxy.network || 'tcp',
}).replace('vless', 'anytls');
// 偷个懒
@@ -5797,6 +5797,26 @@ describe('Proxy text producers', function () {
expect(parsed.password).to.equal('p@ss:w/rd#1?');
});
it('percent-encodes the URI AnyTLS password', function () {
const output = produceExternal('URI', {
type: 'anytls',
name: 'URI AnyTLS Password',
server: 'anytls.example.com',
port: 443,
password: 'p@ss:w/rd#1?',
sni: 'anytls.example.com',
});
expect(
output.startsWith(
'anytls://p%40ss%3Aw%2Frd%231%3F@anytls.example.com:443?',
),
).to.equal(true);
const [parsed] = ProxyUtils.parse(output);
expect(parsed.server).to.equal('anytls.example.com');
expect(parsed.password).to.equal('p@ss:w/rd#1?');
});
it('produces URI Trojan links with vcn from the sidecar', function () {
const output = produceExternal('URI', {
type: 'trojan',