Skip to content

Commit

Permalink
fix(fs): permit square brackets [] in file paths (#21625)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Poxhofer <[email protected]>
  • Loading branch information
RobHannay and secustor authored Apr 21, 2023
1 parent d6b5679 commit b853af2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/util/fs/util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ describe('util/fs/util', () => {
${'/foo'} | ${false}
${'&&'} | ${false}
${';'} | ${true}
${'./[foo]/bar'} | ${true}
`('isValidPath($value) == $expected', ({ value, expected }) => {
expect(isValidPath(value, 'cacheDir')).toBe(expected);
});
Expand Down
2 changes: 1 addition & 1 deletion lib/util/fs/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { logger } from '../../logger';

// http://www.mtu.edu/umc/services/digital/writing/characters-avoid/
// We allow spaces, but not newlines
const restricted = /[[\]#%&<>*?\b\n\r\0!'"|‘“^`]/;
const restricted = /[#%&<>*?\b\n\r\0!'"|‘“^`]/;

function assertBaseDir(path: string, baseDir: string): void {
if (!path.startsWith(baseDir)) {
Expand Down

0 comments on commit b853af2

Please sign in to comment.