Skip to content

Commit

Permalink
fix: allow usage of # and @ in request path
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskari committed Oct 16, 2024
1 parent 6684520 commit d42ff1a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions backend/request-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ export const pathInvalidCharacterFilter = req => {
throw Error('Path contains invalid characters.');
}

// Allow alphanumeric, dashes, underscores, dots, slashes, colons, tildes, question marks, equals, and ampersands
const validPathRegex = /^[a-zA-Z0-9/_\-.:~?&=]+$/;
const validPathRegex = /^[a-zA-Z0-9/_\-.:~?&=#@]+$/;
if (decodedPath.includes('..') || !validPathRegex.test(decodedPath)) {
throw Error(`Path contains invalid characters.`);
}
Expand Down
2 changes: 1 addition & 1 deletion backend/request-filters.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('pathInvalidCharacterFilter tests', () => {
{
description: 'should not throw an error for a valid path',
req: {
originalUrl: '/valid/path-123',
originalUrl: '/valid/path-123@456#789',
},
},
{
Expand Down

0 comments on commit d42ff1a

Please sign in to comment.