| 2529 | } |
| 2530 | |
| 2531 | static bool cbm_hook_script_name_safe(const char *script_name) { |
| 2532 | if (!script_name || !script_name[0]) { |
| 2533 | return false; |
| 2534 | } |
| 2535 | for (const unsigned char *cursor = (const unsigned char *)script_name; *cursor; cursor++) { |
| 2536 | bool safe = (*cursor >= 'a' && *cursor <= 'z') || (*cursor >= 'A' && *cursor <= 'Z') || |
| 2537 | (*cursor >= '0' && *cursor <= '9') || *cursor == '-' || *cursor == '_' || |
| 2538 | *cursor == '.'; |
| 2539 | if (!safe) { |
| 2540 | return false; |
| 2541 | } |
| 2542 | } |
| 2543 | return true; |
| 2544 | } |
| 2545 | |
| 2546 | /* Build the hook command string written into Claude Code's settings.json. |
| 2547 | * POSIX embeds a safely quoted absolute custom config path or a portable $HOME |
no outgoing calls
no test coverage detected