| 2508 | } |
| 2509 | |
| 2510 | static bool cbm_hook_script_name_safe(const char *script_name) { |
| 2511 | if (!script_name || !script_name[0]) { |
| 2512 | return false; |
| 2513 | } |
| 2514 | for (const unsigned char *cursor = (const unsigned char *)script_name; *cursor; cursor++) { |
| 2515 | bool safe = (*cursor >= 'a' && *cursor <= 'z') || (*cursor >= 'A' && *cursor <= 'Z') || |
| 2516 | (*cursor >= '0' && *cursor <= '9') || *cursor == '-' || *cursor == '_' || |
| 2517 | *cursor == '.'; |
| 2518 | if (!safe) { |
| 2519 | return false; |
| 2520 | } |
| 2521 | } |
| 2522 | return true; |
| 2523 | } |
| 2524 | |
| 2525 | /* Build the hook command string written into Claude Code's settings.json. |
| 2526 | * POSIX embeds a safely quoted absolute custom config path or a portable $HOME |
no outgoing calls
no test coverage detected