aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-04-28 22:57:17 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-04-28 22:57:17 -0700
commit1991edf9a560e1b20734b565d85f7ba41752b84a (patch)
treeaf2586b4334a8c1d80fccd2a2cce2df78a2e06da
parent4edc97a921d011489375eac62519fe3fc24f7609 (diff)
downloadpandoc-1991edf9a560e1b20734b565d85f7ba41752b84a.tar.gz
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.
-rw-r--r--src/Text/Pandoc/Shared.hs5
1 files changed, 2 insertions, 3 deletions
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