mirror of
https://github.com/callumalpass/tasknotes.git
synced 2026-07-22 12:50:26 +00:00
fix: automatically sanitize forbidden characters in task titles
- Remove validation that rejects tasks with forbidden filename characters - Allow automatic sanitization via existing sanitizeForFilename() function - Remove "invalid characters" error message from instant task convert - Enable previously skipped test for invalid characters handling - Fixes inconsistent behavior between instant convert and manual creation Fixes #590, Fixes #436
This commit is contained in:
parent
dd56c64a1f
commit
ce30885d4f
2 changed files with 1 additions and 17 deletions
|
|
@ -238,8 +238,6 @@ export class InstantTaskConvertService {
|
|||
console.error('Error during instant task conversion:', error);
|
||||
if (error.message.includes('file already exists')) {
|
||||
new Notice('A file with this name already exists. Please try again or rename the task.');
|
||||
} else if (error.message.includes('invalid characters')) {
|
||||
new Notice('Task title contains invalid characters for filename.');
|
||||
} else {
|
||||
new Notice('Failed to convert task. Please try again.');
|
||||
}
|
||||
|
|
@ -323,18 +321,6 @@ export class InstantTaskConvertService {
|
|||
return { isValid: false, error: 'Task title cannot be empty.' };
|
||||
}
|
||||
|
||||
|
||||
// Validate against dangerous characters for file operations
|
||||
const basicDangerousChars = /[<>:"/\\|?*]/;
|
||||
const hasControlChars = parsedData.title.split('').some(char => {
|
||||
const code = char.charCodeAt(0);
|
||||
return code <= 31 || code === 127;
|
||||
});
|
||||
|
||||
if (basicDangerousChars.test(parsedData.title) || hasControlChars) {
|
||||
return { isValid: false, error: 'Task title contains invalid characters for file operations.' };
|
||||
}
|
||||
|
||||
// Validate date formats if present
|
||||
const dateFields = ['dueDate', 'scheduledDate', 'startDate', 'createdDate', 'doneDate'];
|
||||
for (const field of dateFields) {
|
||||
|
|
|
|||
|
|
@ -452,9 +452,7 @@ describe('Task Creation Workflow Integration', () => {
|
|||
expect(result.cacheUpdated).toBe(false);
|
||||
});
|
||||
|
||||
it.skip('should handle invalid characters in task titles', async () => {
|
||||
// TODO: This test has test isolation issues - passes individually but fails in suite
|
||||
// The functionality works correctly, but the test environment has mock pollution
|
||||
it('should handle invalid characters in task titles', async () => {
|
||||
const taskData = {
|
||||
title: 'Task with invalid chars: <>:"|?*\\/[]'
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue