diff --git a/src/components/layout/layout-traffic.tsx b/src/components/layout/layout-traffic.tsx index 97caa82..f97c6cf 100644 --- a/src/components/layout/layout-traffic.tsx +++ b/src/components/layout/layout-traffic.tsx @@ -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(); } diff --git a/src/components/setting/mods/web-ui-viewer.tsx b/src/components/setting/mods/web-ui-viewer.tsx index ae1bf31..8588d3d 100644 --- a/src/components/setting/mods/web-ui-viewer.tsx +++ b/src/components/setting/mods/web-ui-viewer.tsx @@ -60,7 +60,10 @@ export const WebUIViewer = forwardRef((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); diff --git a/src/pages/connections.tsx b/src/pages/connections.tsx index 3654a61..535d3c0 100644 --- a/src/pages/connections.tsx +++ b/src/pages/connections.tsx @@ -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();