mirror of
https://github.com/Ellpeck/ObsidianJustSharePlease.git
synced 2024-11-26 20:28:34 +01:00
prevent directory traversal on server
This commit is contained in:
parent
d852b61a67
commit
3c59ee5de9
1 changed files with 5 additions and 4 deletions
|
@ -114,13 +114,14 @@ function get_markdown_content(): ?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 {
|
||||
return get_data_path() . $id . ".json";
|
||||
return get_id_base_path($id) . ".json";
|
||||
}
|
||||
|
||||
function get_data_path(): string {
|
||||
return dirname(getcwd()) . "/data/";
|
||||
function get_id_base_path(string $id): string {
|
||||
// ensure id can't be used to traverse into other directories
|
||||
return dirname(getcwd()) . "/data/" . basename($id);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue