addurl --preserve-filename: reject control characters
As well as escape sequences, control characters seem unlikely to be desired when doing addurl, and likely to trip someone up. So disallow them as well. I did consider going the other way and allowing filenames with control characters and escape sequences, since git-annex is in the process of escaping display of all filenames. Might still be a better idea? Also display the illegal filename git quoted when it rejects it. Sponsored-by: Nicholas Golder-Manning on Patreon
This commit is contained in:
parent
1c21ce17d4
commit
da83652c76
4 changed files with 19 additions and 12 deletions
|
@ -52,8 +52,8 @@ sanitizeLeadingFilePathCharacter ('-':s) = '_':s
|
|||
sanitizeLeadingFilePathCharacter ('/':s) = '_':s
|
||||
sanitizeLeadingFilePathCharacter s = s
|
||||
|
||||
escapeSequenceInFilePath :: FilePath -> Bool
|
||||
escapeSequenceInFilePath f = '\ESC' `elem` f
|
||||
controlCharacterInFilePath :: FilePath -> Bool
|
||||
controlCharacterInFilePath = any isControl
|
||||
|
||||
{- ../ is a path traversal, no matter where it appears.
|
||||
-
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue