Memory: harden QMD memory_get path checks
parent
b7f4755020
commit
c248da0317
|
|
@ -280,6 +280,13 @@ export class QmdMemoryManager implements MemorySearchManager {
|
||||||
const relPath = params.relPath?.trim();
|
const relPath = params.relPath?.trim();
|
||||||
if (!relPath) throw new Error("path required");
|
if (!relPath) throw new Error("path required");
|
||||||
const absPath = this.resolveReadPath(relPath);
|
const absPath = this.resolveReadPath(relPath);
|
||||||
|
if (!absPath.endsWith(".md")) {
|
||||||
|
throw new Error("path required");
|
||||||
|
}
|
||||||
|
const stat = await fs.lstat(absPath);
|
||||||
|
if (stat.isSymbolicLink() || !stat.isFile()) {
|
||||||
|
throw new Error("path required");
|
||||||
|
}
|
||||||
const content = await fs.readFile(absPath, "utf-8");
|
const content = await fs.readFile(absPath, "utf-8");
|
||||||
if (!params.from && !params.lines) {
|
if (!params.from && !params.lines) {
|
||||||
return { text: content, path: relPath };
|
return { text: content, path: relPath };
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue