fix: encodeURIComponent secret

This commit is contained in:
GyDi 2023-06-29 14:15:57 +08:00 committed by GitHub
parent c2109d245f
commit 6cf174c5ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -46,7 +46,7 @@ const LayoutTraffic = () => {
if (document.visibilityState === "visible") {
// reconnect websocket
const { server = "", secret = "" } = clashInfo;
connect(`ws://${server}/traffic?token=${secret}`);
connect(`ws://${server}/traffic?token=${encodeURIComponent(secret)}`);
} else {
disconnect();
}

View File

@ -60,7 +60,10 @@ export const WebUIViewer = forwardRef<DialogRef>((props, ref) => {
.trim();
url = url.replaceAll("%port", port || "9090");
url = url.replaceAll("%secret", clashInfo.secret || "");
url = url.replaceAll(
"%secret",
encodeURIComponent(clashInfo.secret || "")
);
}
await openWebUrl(url);

View File

@ -96,7 +96,7 @@ const ConnectionsPage = () => {
if (!clashInfo) return;
const { server = "", secret = "" } = clashInfo;
connect(`ws://${server}/connections?token=${secret}`);
connect(`ws://${server}/connections?token=${encodeURIComponent(secret)}`);
return () => {
disconnect();