| 2444 | } |
| 2445 | |
| 2446 | static bool cbm_hook_script_name_safe(const char *script_name) { |
| 2447 | if (!script_name || !script_name[0]) { |
| 2448 | return false; |
| 2449 | } |
| 2450 | for (const unsigned char *cursor = (const unsigned char *)script_name; *cursor; cursor++) { |
| 2451 | bool safe = (*cursor >= 'a' && *cursor <= 'z') || (*cursor >= 'A' && *cursor <= 'Z') || |
| 2452 | (*cursor >= '0' && *cursor <= '9') || *cursor == '-' || *cursor == '_' || |
| 2453 | *cursor == '.'; |
| 2454 | if (!safe) { |
| 2455 | return false; |
| 2456 | } |
| 2457 | } |
| 2458 | return true; |
| 2459 | } |
| 2460 | |
| 2461 | /* Build the hook command string written into Claude Code's settings.json. |
| 2462 | * POSIX embeds a safely quoted absolute custom config path or a portable $HOME |
no outgoing calls
no test coverage detected