| 2639 | } |
| 2640 | |
| 2641 | static bool cbm_hook_script_name_safe(const char *script_name) { |
| 2642 | if (!script_name || !script_name[0]) { |
| 2643 | return false; |
| 2644 | } |
| 2645 | for (const unsigned char *cursor = (const unsigned char *)script_name; *cursor; cursor++) { |
| 2646 | bool safe = (*cursor >= 'a' && *cursor <= 'z') || (*cursor >= 'A' && *cursor <= 'Z') || |
| 2647 | (*cursor >= '0' && *cursor <= '9') || *cursor == '-' || *cursor == '_' || |
| 2648 | *cursor == '.'; |
| 2649 | if (!safe) { |
| 2650 | return false; |
| 2651 | } |
| 2652 | } |
| 2653 | return true; |
| 2654 | } |
| 2655 | |
| 2656 | /* Build the hook command string written into Claude Code's settings.json. |
| 2657 | * POSIX embeds a safely quoted absolute custom config path or a portable $HOME |
no outgoing calls
no test coverage detected