diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs index 0de4da78f5..fda2a99e0f 100644 --- a/Command/AddUrl.hs +++ b/Command/AddUrl.hs @@ -139,7 +139,7 @@ startWeb relaxed optfile pathdepth s = go $ fromMaybe bad $ parseURI urlstring where (urlstring, downloader) = getDownloader s bad = fromMaybe (error $ "bad url " ++ urlstring) $ - parseURI $ escapeURIString isUnescapedInURI urlstring + Url.parseURIRelaxed $ urlstring go url = case downloader of QuviDownloader -> usequvi _ -> diff --git a/Utility/Url.hs b/Utility/Url.hs index 81a9a1b05f..d8895a9189 100644 --- a/Utility/Url.hs +++ b/Utility/Url.hs @@ -263,7 +263,17 @@ download' quiet url file uo = do {- Allows for spaces and other stuff in urls, properly escaping them. -} parseURIRelaxed :: URLString -> Maybe URI -parseURIRelaxed = parseURI . escapeURIString isAllowedInURI +parseURIRelaxed s = maybe (go escapemore) Just $ go isAllowedInURI + where + go f = parseURI $ escapeURIString f s + {- Some characters like '[' are allowed in eg, the address of + - an uri, but cannot appear unescaped elsewhere in the uri. + - If parsing fails with those characters unescaped, fall back + - to escaping them too. + -} + escapemore '[' = False + escapemore ']' = False + escapemore c = isAllowedInURI c hAcceptEncoding :: CI.CI B.ByteString hAcceptEncoding = "Accept-Encoding" diff --git a/debian/changelog b/debian/changelog index 21811ae18c..f7757bfa09 100644 --- a/debian/changelog +++ b/debian/changelog @@ -28,6 +28,8 @@ git-annex (5.20150529) UNRELEASED; urgency=medium * Fix bug that prevented enumerating locally present objects in repos tuned with annex.tune.objecthash1=true. Fixes: unused, object count in info, unannex. + * Improve url parsing to handle some urls containing illegal [] + characters in their paths. -- Joey Hess Sat, 30 May 2015 02:07:18 -0400