mirror of
https://github.com/rohitg00/skillkit.git
synced 2026-11-20 12:23:29 +00:00
- TLS: default allowSelfSigned=true to preserve self-signed cert workflow; enforce rejectUnauthorized=true when trustedCAs are supplied in client context - Signature verification: verifySecureMessage now cryptographically verifies signatures using PeerIdentity.verifyHex instead of only checking fingerprints - WebSocket: fix timeout handle leak in performClientHandshake; add error logging to empty catch blocks; add per-socket error handler; pre-compute signature once in broadcast(); add send error callbacks; reject startup if TLS configured but certInfo missing - Command parsing: replace broken regex tokenizer with shared splitCommand() utility that correctly handles --flag="value with spaces" - Rate limiter: prefer x-real-ip, fall back to rightmost x-forwarded-for entry - Save route: scope IPv6 prefix checks to actual IPv6 addresses; stop leaking internal error messages to clients - Publish: extract shared parseSkillFrontmatter(); fix getRepoInfo to use async execFileSync; fix path containment checks with separator - Remote transport: add rejectUnauthorized option; bracket IPv6 in URLs; fix host:port splitting for IPv6 with lastIndexOf - Health checks: add tls/tlsAllowSelfSigned to Host type; pass https options - Fetcher: validate owner/repo; derive indexDir from INDEX_PATH - .gitignore: add recursive **/.env pattern, remove redundant entries
60 lines
1.1 KiB
TypeScript
60 lines
1.1 KiB
TypeScript
/**
|
|
* POSIX-like shell word splitting that respects quoted substrings.
|
|
* Handles: simple words, "double quoted", 'single quoted', and
|
|
* --flag="value with spaces" correctly.
|
|
*/
|
|
export function splitCommand(command: string): string[] {
|
|
const tokens: string[] = [];
|
|
let current = "";
|
|
let inSingleQuote = false;
|
|
let inDoubleQuote = false;
|
|
|
|
for (let i = 0; i < command.length; i++) {
|
|
const ch = command[i];
|
|
|
|
if (inSingleQuote) {
|
|
if (ch === "'") {
|
|
inSingleQuote = false;
|
|
} else {
|
|
current += ch;
|
|
}
|
|
continue;
|
|
}
|
|
|
|
if (inDoubleQuote) {
|
|
if (ch === '"') {
|
|
inDoubleQuote = false;
|
|
} else {
|
|
current += ch;
|
|
}
|
|
continue;
|
|
}
|
|
|
|
if (ch === "'") {
|
|
inSingleQuote = true;
|
|
continue;
|
|
}
|
|
|
|
if (ch === '"') {
|
|
inDoubleQuote = true;
|
|
continue;
|
|
}
|
|
|
|
if (ch === " " || ch === "\t") {
|
|
if (current.length > 0) {
|
|
tokens.push(current);
|
|
current = "";
|
|
}
|
|
continue;
|
|
}
|
|
|
|
current += ch;
|
|
}
|
|
|
|
if (current.length > 0) {
|
|
tokens.push(current);
|
|
}
|
|
|
|
return tokens;
|
|
}
|