fix: escape special characters in notification options

This commit is contained in:
NaccOll 2025-08-12 15:26:43 +08:00
parent 76a4560b56
commit 559be9d5b9

View file

@ -78,11 +78,12 @@ export async function showSystemNotification(options: NotificationOptions): Prom
throw new Error("Message is required")
}
const escape = (str: string = "") => str.replace(/\\/g, "\\\\").replace(/"/g, '\\"')
const escapedOptions = {
...options,
title: title.replace(/"/g, '\\"'),
message: message.replace(/"/g, '\\"'),
subtitle: options.subtitle?.replace(/"/g, '\\"') || "",
title: escape(title),
message: escape(message),
subtitle: escape(options.subtitle),
}
switch (platform()) {