deal with attempt to export filename with # or ? to webdav

xporting files with '#' or '?' in their name won't work because urls get
truncated on those. Fail in a better way in this case, and avoid failing
when removing such files from the export, so after the user has renamed the
problem files the export will succeed.
This commit is contained in:
Joey Hess 2019-02-07 13:47:57 -04:00
parent d5c435d3dc
commit 60c1b5c994
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 78 additions and 26 deletions

View file

@ -46,8 +46,14 @@ keyDir k = addTrailingPathSeparator $ hashdir </> keyFile k
keyLocation :: Key -> DavLocation
keyLocation k = keyDir k ++ keyFile k
exportLocation :: ExportLocation -> DavLocation
exportLocation = fromExportLocation
{- Paths containing # or ? cannot be represented in an url, so fails on
- those. -}
exportLocation :: ExportLocation -> Either String DavLocation
exportLocation l =
let p = fromExportLocation l
in if any (`elem` p) ['#', '?']
then Left ("Cannot store file containing '#' or '?' on webdav: " ++ p)
else Right p
{- Where we store temporary data for a key as it's being uploaded. -}
keyTmpLocation :: Key -> DavLocation