Skip to content

Commit 5f017ee

Browse files
authored
Unsanitize characters permissible in Windows paths (#1533)
1 parent 6103266 commit 5f017ee

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/foam-vscode/src/services/note-creation-engine.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,8 @@ foam_template:
499499

500500
const result = await engine.processTemplate(trigger, template, resolver);
501501

502-
// All invalid characters should become dashes
503-
expect(result.filepath.path).toBe('Test-------------Title-----.md');
502+
// All invalid characters should become dashes, and valid should stay unchanged
503+
expect(result.filepath.path).toBe("Test#%&{}----$!'-Title@+`-=.md");
504504

505505
// Content should remain unchanged
506506
expect(result.content).toContain('# Test#%&{}<>?*$!\'"Title@+`|=');

packages/foam-vscode/src/services/note-creation-engine.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import { URI } from '../core/model/uri';
1515
/**
1616
* Characters that are invalid in file names
1717
* Based on UNALLOWED_CHARS from variable-resolver.ts but excluding filepaths
18-
* related chars
18+
* related chars and chars permissible in filepaths
1919
*/
20-
const FILEPATH_UNALLOWED_CHARS = '#%&{}<>?*$!\'"@+`|=';
20+
const FILEPATH_UNALLOWED_CHARS = '<>?*"|';
2121

2222
/**
2323
* Sanitizes a filepath by replacing invalid characters with dashes

0 commit comments

Comments
 (0)