From 1991edf9a560e1b20734b565d85f7ba41752b84a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 28 Apr 2013 22:57:17 -0700 Subject: 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. --- src/Text/Pandoc/Shared.hs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index f8c776e27..bf988875b 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -565,17 +565,16 @@ fetchItem sourceDir s = cont <- B.readFile f return (cont, mime) --- TODO - have this return mime type too - then it can work for google --- chart API, e.g. -- | Read from a URL and return raw data and maybe mime type. openURL :: String -> IO (B.ByteString, Maybe String) openURL u = getBodyAndMimeType `fmap` - browse (setAllowRedirects True >> request (getRequest' u)) + browse (setAllowRedirects True >> request (getRequest' u')) where getBodyAndMimeType (_, r) = (rspBody r, findHeader HdrContentType r) getRequest' uriString = case parseURI uriString of Nothing -> error ("Not a valid URL: " ++ uriString) Just v -> mkRequest GET v + u' = escapeURIString (/= '|') u -- pipes are rejected by Network.URI -- -- Error reporting -- cgit v1.2.3