allow tab in controlCharacterInFilePath

Seems unlikely to have a tab in a path, but it's not a control character
that needs to be prevented either.

Left \n \r \v and \a as other non-threatening control characters
that are still obnoxious to have in a filepath because of how it causes
issues with display and/or with shell scripting.
This commit is contained in:
Joey Hess 2023-04-12 12:31:16 -04:00
parent ad71f005b8
commit de68e3dd4f
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -53,7 +53,12 @@ sanitizeLeadingFilePathCharacter ('/':s) = '_':s
sanitizeLeadingFilePathCharacter s = s
controlCharacterInFilePath :: FilePath -> Bool
controlCharacterInFilePath = any isControl
controlCharacterInFilePath = any (not . safechar)
where
safechar c
| not (isControl c) = True
| c == '\t' = True
| otherwise = False
{- ../ is a path traversal, no matter where it appears.
-