Fix Windows clients sending the wrong path for public sharing

Fixes #73
This commit is contained in:
Bruno Bernardino
2025-06-22 11:19:02 +01:00
parent 7fac7febcf
commit cb95085ea3
4 changed files with 17 additions and 8 deletions

View File

@@ -37,7 +37,16 @@ export const handler: Handlers<Data, FreshContextState> = {
if (
!requestBody.filePath || !requestBody.pathInView || !requestBody.filePath.trim() ||
!requestBody.pathInView.trim() || !requestBody.filePath.startsWith('/') ||
!requestBody.pathInView.trim()
) {
return new Response('Bad Request', { status: 400 });
}
// Fix Windows clients sending the directory path with backslashes
requestBody.filePath = requestBody.filePath.replace(/\\/g, '/');
if (
!requestBody.filePath.startsWith('/') ||
requestBody.filePath.includes('../') || !requestBody.pathInView.startsWith('/') ||
requestBody.pathInView.includes('../')
) {