|
|
@@ -140,12 +140,27 @@ const submitClick = async () => {
|
|
|
|
|
|
const params: any = router.currentRoute.value.query;
|
|
|
if ("redirect" in params && params.redirect) {
|
|
|
- const rawRedirect = decodeURIComponent(params.redirect as string);
|
|
|
- const outerUrl = new URL(rawRedirect, window.location.origin);
|
|
|
- const nested = outerUrl.searchParams.get("redirect");
|
|
|
- const finalRedirect = nested ? decodeURIComponent(nested) : rawRedirect;
|
|
|
+ const decodeOnce = (s: string): string => {
|
|
|
+ try {
|
|
|
+ return decodeURIComponent(s);
|
|
|
+ } catch {
|
|
|
+ return s;
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- const url = new URL(finalRedirect, window.location.origin);
|
|
|
+ const rawRedirect = params.redirect as string;
|
|
|
+ let resolved = decodeOnce(rawRedirect);
|
|
|
+
|
|
|
+ // 若存在嵌套的 redirect 参数,则同样单重解码取其值
|
|
|
+ try {
|
|
|
+ const outerUrl = new URL(resolved, window.location.origin);
|
|
|
+ const nested = outerUrl.searchParams.get("redirect");
|
|
|
+ if (nested) {
|
|
|
+ resolved = decodeOnce(nested);
|
|
|
+ }
|
|
|
+ } catch {}
|
|
|
+
|
|
|
+ const url = new URL(resolved, window.location.origin);
|
|
|
url.searchParams.delete("token");
|
|
|
// url.searchParams.append("token", user.value.token);
|
|
|
window.localStorage.setItem("token", user.value.token);
|