mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-04 08:30:39 +00:00
WebDAV post migration fixes (#2398)
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled
This commit is contained in:
@@ -54,7 +54,7 @@ const ROOT_WEB_DAV_RESPONSE_XML = `<?xml version="1.0" encoding="utf-8"?>
|
||||
</D:propstat>
|
||||
</D:response>
|
||||
<D:response>
|
||||
<D:href>/dav/</D:href>
|
||||
<D:href>/</D:href>
|
||||
<D:propstat>
|
||||
<D:prop>
|
||||
<D:displayname>dav</D:displayname>
|
||||
|
||||
@@ -29,10 +29,6 @@ export const COPY = async ( req, res, _filePath, fileNode, headerLockToken ) =>
|
||||
let destinationPath;
|
||||
try {
|
||||
const destUrl = new URL(destinationHeader, `http://${req.headers.host}`);
|
||||
if ( ! destUrl.pathname.startsWith('/dav/') ) {
|
||||
res.status(400).end( 'Bad Request: Destination must be within WebDAV namespace');
|
||||
return;
|
||||
}
|
||||
destinationPath = destUrl.pathname;
|
||||
if ( ! destinationPath.startsWith('/') ) {
|
||||
destinationPath = `/${destinationPath}`;
|
||||
|
||||
@@ -24,7 +24,7 @@ const getLockResponse = ( lockToken, lockScope, filePath ) => {
|
||||
<D:href>${lockToken}</D:href>
|
||||
</D:locktoken>
|
||||
<D:lockroot>
|
||||
<D:href>/dav${escapeXml(encodeURI(filePath))}</D:href>
|
||||
<D:href>${escapeXml(encodeURI(filePath))}</D:href>
|
||||
</D:lockroot>
|
||||
</D:activelock>
|
||||
</D:lockdiscovery>
|
||||
|
||||
@@ -67,7 +67,7 @@ export const MKCOL = async ( req, res, filePath, fileNode, headerLockToken ) =>
|
||||
|
||||
// Set response headers
|
||||
res.set({
|
||||
Location: `/dav${targetPath}${targetPath.endsWith('/') ? '' : '/'}`,
|
||||
Location: `${targetPath}${targetPath.endsWith('/') ? '' : '/'}`,
|
||||
'Content-Length': '0',
|
||||
});
|
||||
|
||||
|
||||
@@ -30,10 +30,6 @@ export const MOVE = async ( req, res, filePath, fileNode, headerLockToken ) => {
|
||||
let destinationPath;
|
||||
try {
|
||||
const destUrl = new URL(destinationHeader, `http://${req.headers.host}`);
|
||||
if ( ! destUrl.pathname.startsWith('/dav/') ) {
|
||||
res.status(400).end( 'Bad Request: Destination must be within WebDAV namespace');
|
||||
return;
|
||||
}
|
||||
destinationPath = destUrl.pathname; // Remove '/dav' prefix
|
||||
if ( ! destinationPath.startsWith('/') ) {
|
||||
destinationPath = `/${destinationPath}`;
|
||||
|
||||
@@ -46,7 +46,7 @@ const convertToWebDAVPropfindXML = ( fsEntry ) => {
|
||||
const xml = `<?xml version="1.0" encoding="utf-8"?>
|
||||
<D:multistatus xmlns:D="DAV:">
|
||||
<D:response>
|
||||
<D:href>/dav${escapeXml(encodeURI(href))}</D:href>
|
||||
<D:href>${escapeXml(encodeURI(href))}</D:href>
|
||||
<D:propstat>
|
||||
<D:prop>
|
||||
<D:displayname>${escapeXml(fsEntry.name)}</D:displayname>
|
||||
@@ -92,7 +92,7 @@ const convertMultipleToWebDAVPropfindXML = ( selfStat, fsEntries ) => {
|
||||
href += '/';
|
||||
}
|
||||
return ` <D:response>
|
||||
<D:href>/dav${escapeXml(encodeURI(href))}</D:href>
|
||||
<D:href>${escapeXml(encodeURI(href))}</D:href>
|
||||
<D:propstat>
|
||||
<D:prop>
|
||||
<D:displayname>${escapeXml(fsEntry.name)}</D:displayname>
|
||||
|
||||
@@ -5,7 +5,7 @@ import { escapeXml } from '../utils.mjs';
|
||||
const getStubResponse = ( filePath ) => `<?xml version="1.0" encoding="utf-8"?>
|
||||
<D:multistatus xmlns:D="DAV:">
|
||||
<D:response>
|
||||
<D:href>/dav${escapeXml(encodeURI(filePath))}</D:href>
|
||||
<D:href>${escapeXml(encodeURI(filePath))}</D:href>
|
||||
<D:propstat>
|
||||
<D:prop/>
|
||||
<D:status>HTTP/1.1 200 OK</D:status>
|
||||
|
||||
Reference in New Issue
Block a user