fix(app): swallow URIError in assistant file link parser on bare '%'
decodeURIComponent throws on '%' not followed by two hex digits. The two calls inside parseAssistantFileLink and normalizeFileUrlPath had no try/catch, so any timeline message containing strings like '100% packet loss' (ping output), '%PATH%' or '0% off' could escape into the React tree and unmount the agent route, leaving the renderer blank. Wrap both calls in a local safeDecodeURIComponent that returns the input unchanged when decoding fails, mirroring the helper already used in host-routes.ts. Closes #1148
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
import { isAbsolutePath } from "@/utils/path";
|
||||
|
||||
function safeDecodeURIComponent(value: string): string {
|
||||
try {
|
||||
return decodeURIComponent(value);
|
||||
} catch {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
export interface InlinePathTarget {
|
||||
raw: string;
|
||||
path: string;
|
||||
@@ -350,7 +358,7 @@ export function parseAssistantFileLink(
|
||||
return null;
|
||||
}
|
||||
|
||||
const normalizedPath = normalizePathToken(decodeURIComponent(parsedUrl.pathname));
|
||||
const normalizedPath = normalizePathToken(safeDecodeURIComponent(parsedUrl.pathname));
|
||||
if (!normalizedPath || !isAbsolutePath(normalizedPath)) {
|
||||
return null;
|
||||
}
|
||||
@@ -659,7 +667,7 @@ function normalizeFileUrlPath(pathname: string): string | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
const decoded = decodeURIComponent(pathname).replace(/\\/g, "/");
|
||||
const decoded = safeDecodeURIComponent(pathname).replace(/\\/g, "/");
|
||||
if (!decoded) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user