Skip to content

Commit fff64e6

Browse files
committed
Don't patch out network
1 parent 336228b commit fff64e6

File tree

6 files changed

+25
-27
lines changed

6 files changed

+25
-27
lines changed

cabal.project

+8-8
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,8 @@ constraints:
115115

116116
source-repository-package
117117
type: git
118-
location: https://github.com/haskell-wasm/conduit.git
119-
tag: ff33329247f2ef321dcab836e98c1bcfaff2bd13
120-
subdir: conduit-extra
118+
location: https://github.com/haskell-wasm/network.git
119+
tag: ed252fbf8b98bd5724fbc71e23eb5f8ab4305381
121120

122121
source-repository-package
123122
type: git
@@ -130,11 +129,6 @@ source-repository-package
130129
location: https://github.com/haskell-wasm/hs-memory.git
131130
tag: a198a76c584dc2cfdcde6b431968de92a5fed65e
132131

133-
source-repository-package
134-
type: git
135-
location: https://github.com/haskell-wasm/streaming-commons.git
136-
tag: 7e9c38b2fd55ce50d3f74fe708ca47db8c9bb315
137-
138132
source-repository-package
139133
type: git
140134
location: https://github.com/haskell-wasm/xml.git
@@ -146,3 +140,9 @@ source-repository-package
146140
type: git
147141
location: https://github.com/amesgen/splitmix
148142
tag: 5f5b766d97dc735ac228215d240a3bb90bc2ff75
143+
144+
source-repository-package
145+
type: git
146+
location: https://github.com/amesgen/cborg
147+
tag: c3b5c696f62d04c0d87f55250bfc0016ab94d800
148+
subdir: cborg

pandoc.cabal

+7-1
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ library
495495
commonmark-pandoc >= 0.2.2.2 && < 0.3,
496496
containers >= 0.6.0.1 && < 0.8,
497497
crypton >= 0.30 && < 1.1,
498+
crypton-connection >= 0.3.1 && < 0.5,
498499
data-default >= 0.4 && < 0.8,
499500
deepseq >= 1.3 && < 1.6,
500501
directory >= 1.2.3 && < 1.4,
@@ -506,11 +507,14 @@ library
506507
filepath >= 1.1 && < 1.6,
507508
gridtables >= 0.1 && < 0.2,
508509
haddock-library >= 1.10 && < 1.12,
510+
http-client >= 0.4.30 && < 0.8,
511+
http-client-tls >= 0.2.4 && < 0.4,
509512
http-types >= 0.8 && < 0.13,
510513
ipynb >= 0.2 && < 0.3,
511514
jira-wiki-markup >= 1.5.1 && < 1.6,
512515
mime-types >= 0.1.1 && < 0.2,
513516
mtl >= 2.2 && < 2.4,
517+
network >= 2.6 && < 3.3,
514518
network-uri >= 2.6 && < 2.8,
515519
pandoc-types >= 1.23.1 && < 1.24,
516520
parsec >= 3.1 && < 3.2,
@@ -538,7 +542,9 @@ library
538542
xml >= 1.3.12 && < 1.4,
539543
typst >= 0.6 && < 0.6.1,
540544
vector >= 0.12 && < 0.14,
541-
djot >= 0.1.2.2 && < 0.2
545+
djot >= 0.1.2.2 && < 0.2,
546+
tls >= 2.0.1 && < 2.2,
547+
crypton-x509-system >= 1.6.7 && < 1.7
542548

543549
if !os(windows)
544550
build-depends: unix >= 2.4 && < 2.9

src/Text/Pandoc/Class/IO.hs

+10-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,16 @@ import Data.ByteString.Lazy (toChunks)
4141
import Data.Text (Text, pack, unpack)
4242
import Data.Time (TimeZone, UTCTime)
4343
import Data.Unique (hashUnique)
44+
import Network.Connection (TLSSettings(..))
45+
import qualified Network.TLS as TLS
46+
import qualified Network.TLS.Extra as TLS
47+
import Network.HTTP.Client
48+
(httpLbs, responseBody, responseHeaders,
49+
Request(port, host, requestHeaders), parseRequest, newManager)
50+
import Network.HTTP.Client.Internal (addProxy)
51+
import Network.HTTP.Client.TLS (mkManagerSettings)
4452
import Network.HTTP.Types.Header ( hContentType )
53+
import Network.Socket (withSocketsDo)
4554
import Network.URI (URI(..), parseURI, unEscapeString)
4655
import System.Directory (createDirectoryIfMissing)
4756
import System.Environment (getEnv)
@@ -74,6 +83,7 @@ import qualified System.FilePath.Glob
7483
import qualified System.Random
7584
import qualified Text.Pandoc.UTF8 as UTF8
7685
import Data.Default (def)
86+
import System.X509 (getSystemCertificateStore)
7787
#ifndef EMBED_DATA_FILES
7888
import qualified Paths_pandoc as Paths
7989
#endif
@@ -119,9 +129,6 @@ openURL u
119129
| Just (URI{ uriScheme = "data:",
120130
uriPath = upath }) <- parseURI (T.unpack u)
121131
= pure $ extractURIData upath
122-
#if defined(wasm32_HOST_ARCH)
123-
| otherwise = error "Text.Pandoc.Class.IO.openURL"
124-
#else
125132
| otherwise = do
126133
let toReqHeader (n, v) = (CI.mk (UTF8.fromText n), UTF8.fromText v)
127134
customHeaders <- map toReqHeader <$> getsCommonState stRequestHeaders
@@ -161,7 +168,6 @@ openURL u
161168
case res of
162169
Right r -> return r
163170
Left e -> throwError $ PandocHttpError u e
164-
#endif
165171

166172
-- | Read the lazy ByteString contents from a file path, raising an error on
167173
-- failure.

src/Text/Pandoc/Class/PandocMonad.hs

-2
Original file line numberDiff line numberDiff line change
@@ -491,13 +491,11 @@ fillMediaBag d = walkM handleImage d
491491
"replacing image with description"
492492
-- emit alt text
493493
return $ replacementSpan attr src tit lab
494-
#if !defined(wasm32_HOST_ARCH)
495494
PandocHttpError u er -> do
496495
report $ CouldNotFetchResource u
497496
(T.pack $ show er ++ "\rReplacing image with description.")
498497
-- emit alt text
499498
return $ replacementSpan attr src tit lab
500-
#endif
501499
_ -> throwError e)
502500
handleImage x = return x
503501

src/Text/Pandoc/Error.hs

-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{-# LANGUAGE CPP #-}
21
{-# LANGUAGE DeriveDataTypeable #-}
32
{-# LANGUAGE DeriveGeneric #-}
43
{-# LANGUAGE OverloadedStrings #-}
@@ -26,9 +25,7 @@ import Data.Word (Word8)
2625
import Data.Text (Text)
2726
import qualified Data.Text as T
2827
import GHC.Generics (Generic)
29-
#if !defined(wasm32_HOST_ARCH)
3028
import Network.HTTP.Client (HttpException)
31-
#endif
3229
import System.Exit (ExitCode (..), exitWith)
3330
import System.IO (stderr)
3431
import qualified Text.Pandoc.UTF8 as UTF8
@@ -37,9 +34,7 @@ import Text.Pandoc.Shared (tshow)
3734
import Citeproc (CiteprocError, prettyCiteprocError)
3835

3936
data PandocError = PandocIOError Text IOError
40-
#if !defined(wasm32_HOST_ARCH)
4137
| PandocHttpError Text HttpException
42-
#endif
4338
| PandocShouldNeverHappenError Text
4439
| PandocSomeError Text
4540
| PandocParseError Text
@@ -78,10 +73,8 @@ renderError :: PandocError -> Text
7873
renderError e =
7974
case e of
8075
PandocIOError _ err' -> T.pack $ displayException err'
81-
#if !defined(wasm32_HOST_ARCH)
8276
PandocHttpError u err' ->
8377
"Could not fetch " <> u <> "\n" <> tshow err'
84-
#endif
8578
PandocShouldNeverHappenError s ->
8679
"Something we thought was impossible happened!\n" <>
8780
"Please report this to pandoc's developers: " <> s
@@ -176,9 +169,7 @@ handleError (Left e) =
176169
PandocPDFError{} -> 43
177170
PandocXMLError{} -> 44
178171
PandocPDFProgramNotFoundError{} -> 47
179-
#if !defined(wasm32_HOST_ARCH)
180172
PandocHttpError{} -> 61
181-
#endif
182173
PandocShouldNeverHappenError{} -> 62
183174
PandocSomeError{} -> 63
184175
PandocParseError{} -> 64

src/Text/Pandoc/SelfContained.hs

-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{-# LANGUAGE CPP #-}
21
{-# LANGUAGE ScopedTypeVariables #-}
32
{-# LANGUAGE OverloadedStrings #-}
43
{-# LANGUAGE LambdaCase #-}
@@ -423,11 +422,9 @@ getData mimetype src
423422
PandocResourceNotFound r -> do
424423
report $ CouldNotFetchResource r ""
425424
return $ CouldNotFetch e
426-
#if !defined(wasm32_HOST_ARCH)
427425
PandocHttpError u er -> do
428426
report $ CouldNotFetchResource u (tshow er)
429427
return $ CouldNotFetch e
430-
#endif
431428
_ -> throwError e
432429

433430

0 commit comments

Comments
 (0)