git.iko.soy/typeable/pandoc
on master help sign in
Allow https: to work in pandoc command line arguments.

(Use openURL from Shared instead of simpleHTTP.)

commit9b6f1fc495b7b6e4c6d13ef84f600cb3f681d538 authorJohn MacFarlane <jgm@berkeley.edu> dateThu 5 Dec 2013, 11:28 (13 years ago) parent5314df5
1 file changed+8−5
pandoc.hs+8−5
pandoc.hs+8−5
@@ -35,7 +35,8 @@ import Text.Pandoc.Builder (setMeta)
3535import Text.Pandoc.PDF (makePDF)
3636import Text.Pandoc.Readers.LaTeX (handleIncludes)
3737import Text.Pandoc.Shared ( tabFilter, readDataFileUTF8, readDataFile,
38− safeRead, headerShift, normalize, err, warn )
38+ safeRead, headerShift, normalize, err, warn,
39+ openURL )
3940import Text.Pandoc.XML ( toEntities )
4041import Text.Pandoc.SelfContained ( makeSelfContained )
4142import Text.Pandoc.Process (pipeProcess)
@@ -55,7 +56,6 @@ import Control.Exception.Extensible ( throwIO )
5556import qualified Text.Pandoc.UTF8 as UTF8
5657import Control.Monad (when, unless, liftM)
5758import Data.Foldable (foldrM)
58−import Network.HTTP (simpleHTTP, mkRequest, getResponseBody, RequestMethod(..))
5959import Network.URI (parseURI, isURI, URI(..))
6060import qualified Data.ByteString.Lazy as B
6161import qualified Data.ByteString as BS
@@ -1120,10 +1120,13 @@ main = do
11201120 readSource "-" = UTF8.getContents
11211121 readSource src = case parseURI src of
11221122 Just u | uriScheme u `elem` ["http:","https:"] ->
1123− readURI u
1123+ readURI src
11241124 _ -> UTF8.readFile src
1125− readURI uri = simpleHTTP (mkRequest GET uri) >>= getResponseBody >>=
1126− return . UTF8.toStringLazy -- treat all as UTF8
1125+ readURI src = do
1126+ res <- openURL src
1127+ case res of
1128+ Left e -> throwIO e
1129+ Right (bs,_) -> return $ UTF8.toString bs
11271130
11281131 let convertTabs = tabFilter (if preserveTabs then 0 else tabStop)
11291132