mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-11-27 06:43:08 +00:00
fix(uri): percent-encode the trojan password
The URI producer wrote the trojan password as is, so a password with @, :, /, # or ? produced a link that parses back with a different server and password (trojan://p@ss@host -> server 'ss@host', password 'p'). The hysteria2, tuic and anytls producers already encode it.
This commit is contained in:
1 parent
a6d09c7aaa
commit
eda9781cc3
2 files changed
+25
-3
No files matched your search
@@ -1275,9 +1275,11 @@ export default function URI_Producer() {
|
||||
trojanMode = `&mode=${encodeURIComponent(proxy._mode)}`;
|
||||
}
|
||||
}
|
||||
result = `trojan://${proxy.password}@${proxy.server}:${
|
||||
proxy.port
|
||||
}?sni=${encodeURIComponent(proxy.sni || proxy.server)}${
|
||||
result = `trojan://${encodeURIComponent(proxy.password)}@${
|
||||
proxy.server
|
||||
}:${proxy.port}?sni=${encodeURIComponent(
|
||||
proxy.sni || proxy.server,
|
||||
)}${
|
||||
proxy['skip-cert-verify'] ? '&allowInsecure=1' : ''
|
||||
}${trojanTransport}${trojanAlpn}${trojanFp}${trojanPcs}${trojanVcn}${trojanSecurity}${trojanSid}${trojanPbk}${trojanSpx}${trojanMode}${trojanExtra}#${encodeURIComponent(
|
||||
proxy.name,
|
||||
|
||||
@@ -5777,6 +5777,26 @@ describe('Proxy text producers', function () {
|
||||
);
|
||||
});
|
||||
|
||||
it('percent-encodes the URI Trojan password', function () {
|
||||
const proxy = {
|
||||
type: 'trojan',
|
||||
name: 'URI Trojan Password',
|
||||
server: 'trojan.example.com',
|
||||
port: 443,
|
||||
password: 'p@ss:w/rd#1?',
|
||||
tls: true,
|
||||
sni: 'trojan.example.com',
|
||||
};
|
||||
const output = produceExternal('URI', proxy);
|
||||
|
||||
expect(output).to.equal(
|
||||
'trojan://p%40ss%3Aw%2Frd%231%3F@trojan.example.com:443?sni=trojan.example.com#URI%20Trojan%20Password',
|
||||
);
|
||||
const [parsed] = ProxyUtils.parse(output);
|
||||
expect(parsed.server).to.equal('trojan.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',
|
||||
|
||||
Reference in new issue
Block a user