Skip to content

Commit

Permalink
fix: various issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hperrin committed Jul 31, 2022
1 parent 0cbb602 commit e6ae85b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
5 changes: 4 additions & 1 deletion src/FileSystemAdapter/Adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ export default class Adapter implements AdapterInterface {
return null;
}

return path.join('/', url.pathname.substring(baseUrl.length));
return path.join(
'/',
decodeURIComponent(url.pathname.substring(baseUrl.length))
);
}

urlToAbsolutePath(url: URL, baseUrl: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/Methods/Method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export class Method {
return null;
}

return await this.xmlParser.parseStringPromise(xml);
return await this.parseXml(xml);
}

/**
Expand Down
42 changes: 21 additions & 21 deletions src/Methods/PROPFIND.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,29 @@ export class PROPFIND extends Method {
const multiStatus = new MultiStatus();

if (xml != null) {
const requestXml = await this.parseXml(xml);

if (!('propfind' in requestXml)) {
if (!('propfind' in xml)) {
throw new BadRequestError(
'PROPFIND methods requires a propfind element.'
);
}

if ('propname' in requestXml.propfind) {
if ('propname' in xml.propfind) {
propname = true;
}

if (!('allprop' in requestXml.propfind)) {
if (!('allprop' in xml.propfind)) {
allprop = false;
} else if ('include' in requestXml.propfind) {
for (let include of requestXml.propfind.include) {
} else if ('include' in xml.propfind) {
for (let include of xml.propfind.include) {
requestedProps = [
...requestedProps,
...Object.keys(include).filter((name) => name !== '$'),
];
}
}

if ('prop' in requestXml.propfind) {
for (let prop of requestXml.propfind.prop) {
if ('prop' in xml.propfind) {
for (let prop of xml.propfind.prop) {
requestedProps = [
...requestedProps,
...Object.keys(prop).filter((name) => name !== '$'),
Expand Down Expand Up @@ -206,20 +204,22 @@ export class PROPFIND extends Method {
return;
}

let children: Resource[] = [];
try {
children = await resource.getInternalMembers(response.locals.user);
} catch (e: any) {
if (!(e instanceof UnauthorizedError)) {
throw e;
if (await resource.isCollection()) {
let children: Resource[] = [];
try {
children = await resource.getInternalMembers(response.locals.user);
} catch (e: any) {
if (!(e instanceof UnauthorizedError)) {
throw e;
}
// Silently exclude members not visible to the user.
}
// Silently exclude members not visible to the user.
}
level++;
for (let child of children) {
await addResourceProps(child);
level++;
for (let child of children) {
await addResourceProps(child);
}
level--;
}
level--;
};
await addResourceProps(resource);

Expand Down

0 comments on commit e6ae85b

Please sign in to comment.