mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 21:53:28 +08:00
fix: use AppleScript-safe escaping and reduce spawnSync timeout
- Replace JSON.stringify with curly quote substitution for AppleScript compatibility (AppleScript does not support \" backslash escapes) - Reduce spawnSync timeout from 5000ms to 3000ms to leave headroom within the 5s hook deadline
This commit is contained in:
@@ -40,11 +40,14 @@ function extractSummary(message) {
|
||||
|
||||
/**
|
||||
* Send a macOS notification via osascript.
|
||||
* Uses spawnSync with an argument array to avoid shell injection.
|
||||
* AppleScript strings do not support backslash escapes, so we replace
|
||||
* double quotes with curly quotes and strip backslashes before embedding.
|
||||
*/
|
||||
function notifyMacOS(title, body) {
|
||||
const script = `display notification ${JSON.stringify(body)} with title ${JSON.stringify(title)}`;
|
||||
spawnSync('osascript', ['-e', script], { stdio: 'ignore', timeout: 5000 });
|
||||
const safeBody = body.replace(/\\/g, '').replace(/"/g, '\u201C');
|
||||
const safeTitle = title.replace(/\\/g, '').replace(/"/g, '\u201C');
|
||||
const script = `display notification "${safeBody}" with title "${safeTitle}"`;
|
||||
spawnSync('osascript', ['-e', script], { stdio: 'ignore', timeout: 3000 });
|
||||
}
|
||||
|
||||
// TODO: future platform support
|
||||
|
||||
Reference in New Issue
Block a user