fix(ui): validate pathname before assigning to window.location.href in handleError

Guard against non-root-relative paths to prevent DOM-based XSS via
tainted window.location data flowing into the href sink.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
tyh.carl 2026-05-19 16:50:57 +08:00
parent dfe4bf6cef
commit dcf3717b63

View file

@ -353,7 +353,10 @@ export const handleError = async (errorData: string | any) => {
clearTokenCookies();
const browserLocation = getWindowLocation();
if (browserLocation) {
window.location.href = browserLocation.pathname;
const pathname = browserLocation.pathname;
if (pathname.startsWith("/")) {
window.location.href = pathname;
}
}
}
lastErrorTime = currentTime;