mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Allow path segments to start with 2 or more dots
This commit is contained in:
parent
33e9ae4191
commit
6fe6b6ec89
@ -205,9 +205,9 @@ export class BaseFileIdentifierMapper implements FileIdentifierMapper {
|
|||||||
throw new BadRequestHttpError('URL needs a / after the base');
|
throw new BadRequestHttpError('URL needs a / after the base');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path.includes('/..')) {
|
if (path.includes('/../') || path.endsWith('/..')) {
|
||||||
this.logger.warn(`Disallowed /.. segment in URL ${identifier.path}.`);
|
this.logger.warn(`Disallowed /../ segment in URL ${identifier.path}.`);
|
||||||
throw new BadRequestHttpError('Disallowed /.. segment in URL');
|
throw new BadRequestHttpError('Disallowed /../ segment in URL');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,9 +22,13 @@ describe('An BaseFileIdentifierMapper', (): void => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('throws 400 if the input path contains relative parts.', async(): Promise<void> => {
|
it('throws 400 if the input path contains relative parts.', async(): Promise<void> => {
|
||||||
const result = mapper.mapUrlToFilePath({ path: `${base}test/../test2` }, false);
|
let result = mapper.mapUrlToFilePath({ path: `${base}test/../test2` }, false);
|
||||||
await expect(result).rejects.toThrow(BadRequestHttpError);
|
await expect(result).rejects.toThrow(BadRequestHttpError);
|
||||||
await expect(result).rejects.toThrow('Disallowed /.. segment in URL');
|
await expect(result).rejects.toThrow('Disallowed /../ segment in URL');
|
||||||
|
|
||||||
|
result = mapper.mapUrlToFilePath({ path: `${base}test/..` }, false);
|
||||||
|
await expect(result).rejects.toThrow(BadRequestHttpError);
|
||||||
|
await expect(result).rejects.toThrow('Disallowed /../ segment in URL');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the corresponding file path for container identifiers.', async(): Promise<void> => {
|
it('returns the corresponding file path for container identifiers.', async(): Promise<void> => {
|
||||||
|
@ -38,7 +38,7 @@ describe('An ExtensionBasedMapper', (): void => {
|
|||||||
it('throws 400 if the input path contains relative parts.', async(): Promise<void> => {
|
it('throws 400 if the input path contains relative parts.', async(): Promise<void> => {
|
||||||
const result = mapper.mapUrlToFilePath({ path: `${base}test/../test2` }, false);
|
const result = mapper.mapUrlToFilePath({ path: `${base}test/../test2` }, false);
|
||||||
await expect(result).rejects.toThrow(BadRequestHttpError);
|
await expect(result).rejects.toThrow(BadRequestHttpError);
|
||||||
await expect(result).rejects.toThrow('Disallowed /.. segment in URL');
|
await expect(result).rejects.toThrow('Disallowed /../ segment in URL');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the corresponding file path for container identifiers.', async(): Promise<void> => {
|
it('returns the corresponding file path for container identifiers.', async(): Promise<void> => {
|
||||||
|
@ -25,7 +25,7 @@ describe('An FixedContentTypeMapper', (): void => {
|
|||||||
it('throws 400 if the input path contains relative parts.', async(): Promise<void> => {
|
it('throws 400 if the input path contains relative parts.', async(): Promise<void> => {
|
||||||
const result = mapper.mapUrlToFilePath({ path: `${base}test/../test2` }, false);
|
const result = mapper.mapUrlToFilePath({ path: `${base}test/../test2` }, false);
|
||||||
await expect(result).rejects.toThrow(BadRequestHttpError);
|
await expect(result).rejects.toThrow(BadRequestHttpError);
|
||||||
await expect(result).rejects.toThrow('Disallowed /.. segment in URL');
|
await expect(result).rejects.toThrow('Disallowed /../ segment in URL');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the corresponding file path for container identifiers.', async(): Promise<void> => {
|
it('returns the corresponding file path for container identifiers.', async(): Promise<void> => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user