(root: string, rel: string)
| 2632 | } |
| 2633 | |
| 2634 | function resolveSafe(root: string, rel: string): string { |
| 2635 | const abs = path.resolve(root, rel) |
| 2636 | const rootAbs = path.resolve(root) |
| 2637 | if (abs !== rootAbs && !abs.startsWith(rootAbs + path.sep)) { |
| 2638 | throw new Error(`Path escapes vault: ${rel}`) |
| 2639 | } |
| 2640 | return abs |
| 2641 | } |
| 2642 | |
| 2643 | export async function readNote(root: string, rel: string): Promise<NoteContent> { |
| 2644 | const abs = resolveSafe(root, rel) |
no outgoing calls
no test coverage detected