@@ -11,7 +11,6 @@ import (
1111 "strings"
1212 "syscall"
1313 "time"
14- "unicode"
1514
1615 "github.com/goccy/go-json"
1716)
@@ -30,17 +29,18 @@ func (l *CheckTasksched) addTasks(ctx context.Context, snc *Agent, check *CheckD
3029 }
3130 }
3231
32+ titleRuneBlacklist := []rune {'\\' , '/' , ':' , '*' , '?' , '"' , '<' , '>' , '|' }
3333 if l .TaskTitle != CheckTaskschedDefaultTaskTitle {
34- if strings .ContainsFunc (l .TaskTitle , func (r rune ) bool { return ! unicode . IsLetter ( r ) }) {
35- return fmt .Errorf ("custom specified title should be all letters, but it isnt: %s " , l .TaskTitle )
34+ if strings .ContainsFunc (l .TaskTitle , func (r rune ) bool { return slices . Contains ( titleRuneBlacklist , r ) }) {
35+ return fmt .Errorf ("custom specified title: '%s' contains one of the blacklisted runes: '%s' " , l .TaskTitle , string ( titleRuneBlacklist ) )
3636 }
3737 }
3838
39+ // allow backslashes when specifying folders, to specify nested paths
40+ folderRuneBlacklist := []rune {'/' , ':' , '*' , '?' , '"' , '<' , '>' , '|' }
3941 if l .Folder != CheckTaskschedDefaultFolder {
40- // NTFS characters are generally allowed, expect quotes
41- allowedRunes := []rune {' ' , '-' , '\\' , '_' , '(' , ')' , '[' , ']' , '.' , ',' }
42- if strings .ContainsFunc (l .Folder , func (r rune ) bool { return ! unicode .IsLetter (r ) && ! slices .Contains (allowedRunes , r ) }) {
43- return fmt .Errorf ("custom specified folder should be all letters or allowed runes: '%s', but it isnt: %s" , string (allowedRunes ), l .Folder )
42+ if strings .ContainsFunc (l .Folder , func (r rune ) bool { return slices .Contains (folderRuneBlacklist , r ) }) {
43+ return fmt .Errorf ("custom specified folder: '%s' contains one of the blacklisted runes: '%s' " , l .Folder , string (folderRuneBlacklist ))
4444 }
4545 }
4646
0 commit comments