Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
fix(backend:webdav): ensure lock paths in headers are decoded correctly
johavenceb2f3880327
diff --git a/backend/src/applications/webdav/guards/webdav-protocol.guard.ts b/backend/src/applications/webdav/guards/webdav-protocol.guard.tsindex 9bff9b62..d78cbb19 100644--- a/backend/src/applications/webdav/guards/webdav-protocol.guard.ts+++ b/backend/src/applications/webdav/guards/webdav-protocol.guard.ts@@ -237,7 +237,7 @@ export class WebDAVProtocolGuard implements CanActivate {if (!req.headers[HEADER.DESTINATION]) {throw new HttpException(`Missing ${HEADER.DESTINATION} header`, HttpStatus.BAD_REQUEST)}- const destination = decodeUrl(urlToPath(req.headers[HEADER.DESTINATION] as string))+ const destination = urlToPath(req.headers[HEADER.DESTINATION] as string)if (!REGEX_BASE_PATH.test(destination)) {this.logger.warn(`The destination does not match the webdav base path : ${destination}`)throw new HttpException('The destination does not match', HttpStatus.BAD_REQUEST)diff --git a/backend/src/common/functions.ts b/backend/src/common/functions.tsindex 41f6cc1c..7058aaba 100755--- a/backend/src/common/functions.ts+++ b/backend/src/common/functions.ts@@ -13,6 +13,7 @@ import { ValidatorOptions } from 'class-validator/types/validation/ValidatorOptiimport crypto from 'node:crypto'import { setTimeout } from 'node:timers/promises'import { SPACE_PERMS_SEP } from '../applications/spaces/constants/spaces'+import { decodeUrl } from './shared'export const regexpEscape = /[.*+?^${}()|[\]\\]/gexport const regexSpecialChars = /[-[\]{}()*+!<=:?./\\^$|#,]/g@@ -56,13 +57,15 @@ export function formatDateISOString(date: Date): string {export function urlToPath(url: string): string {// transform https://sync-in.com/webdav/ to /webdav/+ let path: stringtry {// transform https://sync-in.com/webdav/ to /webdav/- return new URL(url).pathname+ path = new URL(url).pathname} catch {// or allows uri like : /webdav/- return url+ path = url}+ return decodeUrl(path)}export async function hashPassword(password: string): Promise<string> {