webdav: Fix lack of url-escaping of filenames.

inDAVLocation does not url-escape, and so exporting a filename with spaces
to box.com at least resulted in a error 400.

It might also have affected storing keys on a webdav remote, if the key
contained a space or other problem character. Pretty unlikely.

I emailed Clint about the inDAVLocation gotcha, but seems best to fix it
here.

This commit was supported by the NSF-funded DataLad project.
This commit is contained in:
Joey Hess 2017-09-12 15:45:03 -04:00
parent 7f8892f2d2
commit e177bb1e25
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 7 additions and 2 deletions

View file

@ -14,6 +14,8 @@ git-annex (6.20170819) UNRELEASED; urgency=medium
triggered a bug in its webdav support that generates an infinite series triggered a bug in its webdav support that generates an infinite series
of redirects. Deal with such problems by assuming such behavior means of redirects. Deal with such problems by assuming such behavior means
the file is not present. the file is not present.
* webdav: Fix lack of url-escaping of filenames. Mostly impacted exports
of filenames containing eg spaces.
-- Joey Hess <id@joeyh.name> Mon, 28 Aug 2017 12:20:59 -0400 -- Joey Hess <id@joeyh.name> Mon, 28 Aug 2017 12:20:59 -0400

View file

@ -21,14 +21,17 @@ import Utility.Split
import System.FilePath.Posix -- for manipulating url paths import System.FilePath.Posix -- for manipulating url paths
import Network.Protocol.HTTP.DAV (inDAVLocation, DAVT) import Network.Protocol.HTTP.DAV (inDAVLocation, DAVT)
import Control.Monad.IO.Class (MonadIO) import Control.Monad.IO.Class (MonadIO)
import Network.URI
import Data.Default import Data.Default
-- Relative to the top of the DAV url. -- Relative to the top of the DAV url.
type DavLocation = String type DavLocation = String
{- Runs action in subdirectory, relative to the current location. -} {- Runs action with a new location relative to the current location. -}
inLocation :: (MonadIO m) => DavLocation -> DAVT m a -> DAVT m a inLocation :: (MonadIO m) => DavLocation -> DAVT m a -> DAVT m a
inLocation d = inDAVLocation (</> d) inLocation d = inDAVLocation (</> d')
where
d' = escapeURIString isUnescapedInURI d
{- The directory where files(s) for a key are stored. -} {- The directory where files(s) for a key are stored. -}
keyDir :: Key -> DavLocation keyDir :: Key -> DavLocation