diff options
author | John MacFarlane <jgm@berkeley.edu> | 2010-11-12 18:30:50 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2010-11-12 18:30:50 -0800 |
commit | c2636e61d784e88c4a2c8916fdf564266dd7cabd (patch) | |
tree | e004fe37c97c921477f0e03855d71fe63dada1d3 | |
parent | ca51bbbf166b8fd5d835426e1f499d251f2c110c (diff) | |
download | pandoc-c2636e61d784e88c4a2c8916fdf564266dd7cabd.tar.gz |
Treat argument as URI only if it has http(s) scheme.
Previously pandoc would treat the c: in some windowns filespecs
as a URI scheme and try to download... Thanks to Peter Wang for
pointing this out.
-rw-r--r-- | src/pandoc.hs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/pandoc.hs b/src/pandoc.hs index 082e337f5..4caabdd29 100644 --- a/src/pandoc.hs +++ b/src/pandoc.hs @@ -51,7 +51,7 @@ import Text.Pandoc.Biblio #endif import Control.Monad (when, unless, liftM) import Network.HTTP (simpleHTTP, mkRequest, getResponseBody, RequestMethod(..)) -import Network.URI (parseURI, isURI) +import Network.URI (parseURI, isURI, URI(..)) import qualified Data.ByteString.Lazy as B import Data.ByteString.Lazy.UTF8 (toString, fromString) import Codec.Binary.UTF8.String (decodeString, encodeString) @@ -835,8 +835,9 @@ main = do readSources srcs = mapM readSource srcs readSource "-" = UTF8.getContents readSource src = case parseURI src of - Just u -> readURI u - Nothing -> UTF8.readFile src + Just u | uriScheme u `elem` ["http:","https:"] -> + readURI u + _ -> UTF8.readFile src readURI uri = simpleHTTP (mkRequest GET uri) >>= getResponseBody >>= return . toString -- treat all as UTF8 |