| 3022 | } |
| 3023 | |
| 3024 | static bool cbm_hook_script_name_safe(const char *script_name) { |
| 3025 | if (!script_name || !script_name[0]) { |
| 3026 | return false; |
| 3027 | } |
| 3028 | for (const unsigned char *cursor = (const unsigned char *)script_name; *cursor; cursor++) { |
| 3029 | bool safe = (*cursor >= 'a' && *cursor <= 'z') || (*cursor >= 'A' && *cursor <= 'Z') || |
| 3030 | (*cursor >= '0' && *cursor <= '9') || *cursor == '-' || *cursor == '_' || |
| 3031 | *cursor == '.'; |
| 3032 | if (!safe) { |
| 3033 | return false; |
| 3034 | } |
| 3035 | } |
| 3036 | return true; |
| 3037 | } |
| 3038 | |
| 3039 | /* Build the hook command string written into Claude Code's settings.json. |
| 3040 | * POSIX embeds a safely quoted absolute custom config path or a portable $HOME |
no outgoing calls
no test coverage detected