* Check if a string contains ASCII control characters (0x00-0x1F, 0x7F). * These can act as command separators in shells (newlines, carriage returns, etc.). * Allows printable ASCII and Unicode (CJK, emoji, accented chars, etc.).
(s: string)
| 34 | * Allows printable ASCII and Unicode (CJK, emoji, accented chars, etc.). |
| 35 | */ |
| 36 | function containsControlChars(s: string): boolean { |
| 37 | for (let i = 0; i < s.length; i++) { |
| 38 | const code = s.charCodeAt(i) |
| 39 | if (code <= 0x1f || code === 0x7f) { |
| 40 | return true |
| 41 | } |
| 42 | } |
| 43 | return false |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * GitHub owner/repo slug: alphanumerics, dots, hyphens, underscores, |