prevent directory traversal on server

This commit is contained in:
Ell 2023-08-18 13:03:03 +02:00
parent d852b61a67
commit 3c59ee5de9

View file

@ -114,13 +114,14 @@ function get_markdown_content(): ?string {
} }
function get_markdown_path(string $id): string { function get_markdown_path(string $id): string {
return get_data_path() . $id . ".md"; return get_id_base_path($id) . ".md";
} }
function get_meta_path(string $id): string { function get_meta_path(string $id): string {
return get_data_path() . $id . ".json"; return get_id_base_path($id) . ".json";
} }
function get_data_path(): string { function get_id_base_path(string $id): string {
return dirname(getcwd()) . "/data/"; // ensure id can't be used to traverse into other directories
return dirname(getcwd()) . "/data/" . basename($id);
} }