Revert xml lib, to avoid unexpected issues

This commit is contained in:
Bruno Bernardino
2025-10-17 20:52:07 +01:00
parent 6280228759
commit b2dda31c51
4 changed files with 26 additions and 14 deletions

View File

@@ -33,6 +33,7 @@
"fresh/": "https://deno.land/x/fresh@1.7.3/", "fresh/": "https://deno.land/x/fresh@1.7.3/",
"$fresh/": "https://deno.land/x/fresh@1.7.3/", "$fresh/": "https://deno.land/x/fresh@1.7.3/",
"@libs/xml": "https://deno.land/x/xml@2.1.3/mod.ts",
"postgres": "jsr:@db/postgres@0.19.5", "postgres": "jsr:@db/postgres@0.19.5",
"@b-fuze/deno-dom": "jsr:@b-fuze/deno-dom@0.1.56", "@b-fuze/deno-dom": "jsr:@b-fuze/deno-dom@0.1.56",
@@ -40,7 +41,6 @@
"@hexagon/croner": "jsr:@hexagon/croner@9.1.0", "@hexagon/croner": "jsr:@hexagon/croner@9.1.0",
"@mikaelporttila/rss": "jsr:@mikaelporttila/rss@1.1.3", "@mikaelporttila/rss": "jsr:@mikaelporttila/rss@1.1.3",
"@libs/qrcode": "jsr:@libs/qrcode@3.0.0", "@libs/qrcode": "jsr:@libs/qrcode@3.0.0",
"@libs/xml": "jsr:@libs/xml@7.0.2",
"@simplewebauthn/server": "jsr:@simplewebauthn/server@13.2.1", "@simplewebauthn/server": "jsr:@simplewebauthn/server@13.2.1",
"@simplewebauthn/browser": "jsr:@simplewebauthn/browser@13.2.0", "@simplewebauthn/browser": "jsr:@simplewebauthn/browser@13.2.0",
"@std/assert": "jsr:@std/assert@1.0.14", "@std/assert": "jsr:@std/assert@1.0.14",

View File

@@ -12,7 +12,7 @@ export function addDavPrefixToKeys(object: Record<string, any>, prefix = 'D:'):
if (typeof object === 'object' && object !== null) { if (typeof object === 'object' && object !== null) {
return Object.entries(object).reduce((reducedObject, [key, value]) => { return Object.entries(object).reduce((reducedObject, [key, value]) => {
const prefixedKey = key.startsWith('#') || key.startsWith('@') ? key : `${prefix}${key}`; const prefixedKey = key === 'xml' || key.startsWith('#') || key.startsWith('@') ? key : `${prefix}${key}`;
reducedObject[prefixedKey] = addDavPrefixToKeys(value); reducedObject[prefixedKey] = addDavPrefixToKeys(value);
return reducedObject; return reducedObject;
}, {} as Record<string, any>); }, {} as Record<string, any>);
@@ -105,8 +105,10 @@ export async function buildPropFindResponse(
const filePaths = await getFilePaths(join(rootPath, queryPath), depth); const filePaths = await getFilePaths(join(rootPath, queryPath), depth);
const response: Record<string, any> = { const response: Record<string, any> = {
'@version': '1.0', xml: {
'@encoding': 'UTF-8', '@version': '1.0',
'@encoding': 'UTF-8',
},
multistatus: { multistatus: {
'@xmlns:D': 'DAV:', '@xmlns:D': 'DAV:',
response: [], response: [],

View File

@@ -135,8 +135,10 @@ Deno.test('that @libs/xml.parse works', () => {
</prop> </prop>
</propfind>`, </propfind>`,
expected: { expected: {
'@version': '1.0', xml: {
'@encoding': 'UTF-8', '@version': 1,
'@encoding': 'UTF-8',
},
propfind: { propfind: {
'@xmlns': 'DAV:', '@xmlns': 'DAV:',
prop: { prop: {
@@ -153,8 +155,10 @@ Deno.test('that @libs/xml.parse works', () => {
</D:prop> </D:prop>
</D:propfind>`, </D:propfind>`,
expected: { expected: {
'@version': '1.0', xml: {
'@encoding': 'UTF-8', '@version': 1,
'@encoding': 'UTF-8',
},
'D:propfind': { 'D:propfind': {
'@xmlns:D': 'DAV:', '@xmlns:D': 'DAV:',
'D:prop': { 'D:prop': {
@@ -175,8 +179,10 @@ Deno.test('that @libs/xml.stringify works', () => {
const tests: { input: Record<string, any>; expected: string }[] = [ const tests: { input: Record<string, any>; expected: string }[] = [
{ {
input: { input: {
'@version': '1.0', xml: {
'@encoding': 'UTF-8', '@version': '1.0',
'@encoding': 'UTF-8',
},
'D:propfind': { 'D:propfind': {
'D:prop': { 'D:prop': {
'D:displayname': 'test', 'D:displayname': 'test',
@@ -192,8 +198,10 @@ Deno.test('that @libs/xml.stringify works', () => {
}, },
{ {
input: { input: {
'@version': '1.0', xml: {
'@encoding': 'UTF-8', '@version': '1.0',
'@encoding': 'UTF-8',
},
'D:propfind': { 'D:propfind': {
'@xmlns:D': 'DAV:', '@xmlns:D': 'DAV:',
'D:prop': { 'D:prop': {

View File

@@ -168,8 +168,10 @@ export const handler: Handler<Data, FreshContextState> = async (request, context
await lock.acquire(); await lock.acquire();
const responseXml: Record<string, any> = { const responseXml: Record<string, any> = {
'@version': '1.0', xml: {
'@encoding': 'UTF-8', '@version': '1.0',
'@encoding': 'UTF-8',
},
prop: { prop: {
'@xmlns:D': 'DAV:', '@xmlns:D': 'DAV:',
lockdiscovery: { lockdiscovery: {