refactor: improve config path handling and clean up code

- Allow specifying project root or cfg dir for config
- Remove verbose debug print statements during load
- Remove unused site.page action find operation
- Improve validation for relative paths in remove list
This commit is contained in:
Mahmoud-Emad
2025-08-03 18:07:53 +03:00
parent 2502f0a655
commit 44effe9a4b
2 changed files with 14 additions and 10 deletions

View File

@@ -47,7 +47,7 @@ pub fn rm(todelete_ string) ! {
}
item = item.replace('~', os.home_dir())
if item.starts_with('/') {
if os.exists(item) {
console.print_debug(' - rm: ${item}')
@@ -76,8 +76,10 @@ pub fn rm(todelete_ string) ! {
}
}
} else {
if item.contains('/') {
return error('there should be no / in to remove list')
// Handle relative paths - they can contain '/' as long as they're valid relative paths
if item.contains('/') && !item.starts_with('./') && !item.starts_with('../')
&& item.contains('..') {
return error('relative paths with .. are not allowed for security: ${item}')
}
cmd_delete(item)! // look for the command, if will be removed if found
}