git.iko.soy/typeable/pandoc
on master help sign in
Shared.openURL: URL-escape pipe characters.

Even though these are legal, Network.URI doesn't regard them as legal in URLs. So we escape them first. Closes #535.

commit1991edf9a560e1b20734b565d85f7ba41752b84a authorJohn MacFarlane <fiddlosopher@gmail.com> dateSun 28 Apr 2013, 22:57 (14 years ago) parent4edc97a
1 file changed+2−3
src/Text/Pandoc/Shared.hs+2−3
src/Text/Pandoc/Shared.hs+2−3
@@ -565,17 +565,16 @@ fetchItem sourceDir s =
565565 cont <- B.readFile f
566566 return (cont, mime)
567567
568−-- TODO - have this return mime type too - then it can work for google
569−-- chart API, e.g.
570568-- | Read from a URL and return raw data and maybe mime type.
571569openURL :: String -> IO (B.ByteString, Maybe String)
572570openURL u = getBodyAndMimeType `fmap`
573− browse (setAllowRedirects True >> request (getRequest' u))
571+ browse (setAllowRedirects True >> request (getRequest' u'))
574572 where getBodyAndMimeType (_, r) = (rspBody r, findHeader HdrContentType r)
575573 getRequest' uriString = case parseURI uriString of
576574 Nothing -> error ("Not a valid URL: " ++
577575 uriString)
578576 Just v -> mkRequest GET v
577+ u' = escapeURIString (/= '|') u -- pipes are rejected by Network.URI
579578
580579--
581580-- Error reporting