removed redundant code
Massimo Melina committed
Mar 17, 2026 at 18:16 UTC
8f1d88673ce8c06248b451380485911215cbe347
1 file changed
+3
-7
src/webdav.ts
+3
-7
@@ -218,8 +218,8 @@ export async function handledWebdav(ctx: Koa.Context) {
218
return `<?xml version="1.0" encoding="utf-8"?><prop xmlns="DAV:"><lockdiscovery><activelock>
219
<locktype><write/></locktype>
220
<lockscope><exclusive/></lockscope>
221
- <locktoken><href>${escapeXml(token)}</href></locktoken>
222
- <lockroot><href>${escapeXml(path)}</href></lockroot>
221
+ <locktoken><href>${_.escape(token)}</href></locktoken>
222
+ <lockroot><href>${_.escape(path)}</href></lockroot>
223
<depth>0</depth>
224
<timeout>Second-${seconds}</timeout>
225
</activelock></lockdiscovery></prop>`
@@ -259,7 +259,7 @@ export async function handledWebdav(ctx: Koa.Context) {
259
const isDir = await nodeIsFolder(node)
260
const st = await nodeStats(node)
261
res.write(`<response>
262
- <href>${escapeXml(outPath + (append ? pathEncode(name, true) + (isDir ? '/' : '') : ''))}</href>
262
+ <href>${_.escape(outPath + (append ? pathEncode(name, true) + (isDir ? '/' : '') : ''))}</href>
263
<propstat>
264
<status>HTTP/1.1 200 OK</status>
265
<prop>
@@ -311,10 +311,6 @@ export async function handledWebdav(ctx: Koa.Context) {
311
312
}
313
314
-function escapeXml(value: string) {
315
- return value.replace(/[<>&'\"]/g, c => ({ '<': '<', '>': '>', '&': '&', "'": ''', '"': '"', }[c] || c))
316
-}
317
-
314
function compileWebdavAgentRegex(v: boolean|string) {
315
return !v ? null : v === true ? /.*/ : new RegExp(v.trim(), 'i')
316
}