fix: reject cmd.exe caret and control chars; fix subprocess lifecycle bugs in runIngest
This commit is contained in:
@@ -26,6 +26,14 @@ test("isSafeFilename rejects shell metacharacters", () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("isSafeFilename rejects the cmd.exe escape character and control characters", () => {
|
||||
// `^` escapes the next character in cmd.exe, so it can defuse the closing
|
||||
// quote. NUL additionally makes spawn() throw synchronously.
|
||||
for (const bad of ["a^b.md", "a\u0000b.md", "a\u001bb.md", "a\u007fb.md"]) {
|
||||
assert.equal(isSafeFilename(bad), false, `should reject: ${JSON.stringify(bad)}`);
|
||||
}
|
||||
});
|
||||
|
||||
test("isSafeFilename rejects path traversal", () => {
|
||||
assert.equal(isSafeFilename("../secrets.md"), false);
|
||||
assert.equal(isSafeFilename("a/../../b.md"), false);
|
||||
|
||||
Reference in New Issue
Block a user