Skip to content

Don't patch out network #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: wasm
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ constraints:
unix installed,
xhtml installed

-- https://github.com/haskell/network/pull/598
source-repository-package
type: git
location: https://github.com/haskell-wasm/conduit.git
tag: ff33329247f2ef321dcab836e98c1bcfaff2bd13
subdir: conduit-extra
location: https://github.com/haskell-wasm/network.git
tag: ab92e48e9fdf3abe214f85fdbe5301c1280e14e9

source-repository-package
type: git
Expand All @@ -130,11 +130,6 @@ source-repository-package
location: https://github.com/haskell-wasm/hs-memory.git
tag: a198a76c584dc2cfdcde6b431968de92a5fed65e

source-repository-package
type: git
location: https://github.com/haskell-wasm/streaming-commons.git
tag: 7e9c38b2fd55ce50d3f74fe708ca47db8c9bb315

source-repository-package
type: git
location: https://github.com/haskell-wasm/xml.git
Expand All @@ -146,3 +141,9 @@ source-repository-package
type: git
location: https://github.com/amesgen/splitmix
tag: 5f5b766d97dc735ac228215d240a3bb90bc2ff75

source-repository-package
type: git
location: https://github.com/amesgen/cborg
tag: c3b5c696f62d04c0d87f55250bfc0016ab94d800
subdir: cborg
8 changes: 7 additions & 1 deletion pandoc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ library
commonmark-pandoc >= 0.2.2.2 && < 0.3,
containers >= 0.6.0.1 && < 0.8,
crypton >= 0.30 && < 1.1,
crypton-connection >= 0.3.1 && < 0.5,
data-default >= 0.4 && < 0.8,
deepseq >= 1.3 && < 1.6,
directory >= 1.2.3 && < 1.4,
Expand All @@ -506,11 +507,14 @@ library
filepath >= 1.1 && < 1.6,
gridtables >= 0.1 && < 0.2,
haddock-library >= 1.10 && < 1.12,
http-client >= 0.4.30 && < 0.8,
http-client-tls >= 0.2.4 && < 0.4,
http-types >= 0.8 && < 0.13,
ipynb >= 0.2 && < 0.3,
jira-wiki-markup >= 1.5.1 && < 1.6,
mime-types >= 0.1.1 && < 0.2,
mtl >= 2.2 && < 2.4,
network >= 2.6 && < 3.3,
network-uri >= 2.6 && < 2.8,
pandoc-types >= 1.23.1 && < 1.24,
parsec >= 3.1 && < 3.2,
Expand Down Expand Up @@ -538,7 +542,9 @@ library
xml >= 1.3.12 && < 1.4,
typst >= 0.6 && < 0.6.1,
vector >= 0.12 && < 0.14,
djot >= 0.1.2.2 && < 0.2
djot >= 0.1.2.2 && < 0.2,
tls >= 2.0.1 && < 2.2,
crypton-x509-system >= 1.6.7 && < 1.7

if !os(windows)
build-depends: unix >= 2.4 && < 2.9
Expand Down
14 changes: 10 additions & 4 deletions src/Text/Pandoc/Class/IO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,16 @@ import Data.ByteString.Lazy (toChunks)
import Data.Text (Text, pack, unpack)
import Data.Time (TimeZone, UTCTime)
import Data.Unique (hashUnique)
import Network.Connection (TLSSettings(..))
import qualified Network.TLS as TLS
import qualified Network.TLS.Extra as TLS
import Network.HTTP.Client
(httpLbs, responseBody, responseHeaders,
Request(port, host, requestHeaders), parseRequest, newManager)
import Network.HTTP.Client.Internal (addProxy)
import Network.HTTP.Client.TLS (mkManagerSettings)
import Network.HTTP.Types.Header ( hContentType )
import Network.Socket (withSocketsDo)
import Network.URI (URI(..), parseURI, unEscapeString)
import System.Directory (createDirectoryIfMissing)
import System.Environment (getEnv)
Expand Down Expand Up @@ -74,6 +83,7 @@ import qualified System.FilePath.Glob
import qualified System.Random
import qualified Text.Pandoc.UTF8 as UTF8
import Data.Default (def)
import System.X509 (getSystemCertificateStore)
#ifndef EMBED_DATA_FILES
import qualified Paths_pandoc as Paths
#endif
Expand Down Expand Up @@ -119,9 +129,6 @@ openURL u
| Just (URI{ uriScheme = "data:",
uriPath = upath }) <- parseURI (T.unpack u)
= pure $ extractURIData upath
#if defined(wasm32_HOST_ARCH)
| otherwise = error "Text.Pandoc.Class.IO.openURL"
#else
| otherwise = do
let toReqHeader (n, v) = (CI.mk (UTF8.fromText n), UTF8.fromText v)
customHeaders <- map toReqHeader <$> getsCommonState stRequestHeaders
Expand Down Expand Up @@ -161,7 +168,6 @@ openURL u
case res of
Right r -> return r
Left e -> throwError $ PandocHttpError u e
#endif

-- | Read the lazy ByteString contents from a file path, raising an error on
-- failure.
Expand Down
2 changes: 0 additions & 2 deletions src/Text/Pandoc/Class/PandocMonad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -491,13 +491,11 @@ fillMediaBag d = walkM handleImage d
"replacing image with description"
-- emit alt text
return $ replacementSpan attr src tit lab
#if !defined(wasm32_HOST_ARCH)
PandocHttpError u er -> do
report $ CouldNotFetchResource u
(T.pack $ show er ++ "\rReplacing image with description.")
-- emit alt text
return $ replacementSpan attr src tit lab
#endif
_ -> throwError e)
handleImage x = return x

Expand Down
9 changes: 0 additions & 9 deletions src/Text/Pandoc/Error.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
Expand Down Expand Up @@ -26,9 +25,7 @@ import Data.Word (Word8)
import Data.Text (Text)
import qualified Data.Text as T
import GHC.Generics (Generic)
#if !defined(wasm32_HOST_ARCH)
import Network.HTTP.Client (HttpException)
#endif
import System.Exit (ExitCode (..), exitWith)
import System.IO (stderr)
import qualified Text.Pandoc.UTF8 as UTF8
Expand All @@ -37,9 +34,7 @@ import Text.Pandoc.Shared (tshow)
import Citeproc (CiteprocError, prettyCiteprocError)

data PandocError = PandocIOError Text IOError
#if !defined(wasm32_HOST_ARCH)
| PandocHttpError Text HttpException
#endif
| PandocShouldNeverHappenError Text
| PandocSomeError Text
| PandocParseError Text
Expand Down Expand Up @@ -78,10 +73,8 @@ renderError :: PandocError -> Text
renderError e =
case e of
PandocIOError _ err' -> T.pack $ displayException err'
#if !defined(wasm32_HOST_ARCH)
PandocHttpError u err' ->
"Could not fetch " <> u <> "\n" <> tshow err'
#endif
PandocShouldNeverHappenError s ->
"Something we thought was impossible happened!\n" <>
"Please report this to pandoc's developers: " <> s
Expand Down Expand Up @@ -176,9 +169,7 @@ handleError (Left e) =
PandocPDFError{} -> 43
PandocXMLError{} -> 44
PandocPDFProgramNotFoundError{} -> 47
#if !defined(wasm32_HOST_ARCH)
PandocHttpError{} -> 61
#endif
PandocShouldNeverHappenError{} -> 62
PandocSomeError{} -> 63
PandocParseError{} -> 64
Expand Down
3 changes: 0 additions & 3 deletions src/Text/Pandoc/SelfContained.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE LambdaCase #-}
Expand Down Expand Up @@ -423,11 +422,9 @@ getData mimetype src
PandocResourceNotFound r -> do
report $ CouldNotFetchResource r ""
return $ CouldNotFetch e
#if !defined(wasm32_HOST_ARCH)
PandocHttpError u er -> do
report $ CouldNotFetchResource u (tshow er)
return $ CouldNotFetch e
#endif
_ -> throwError e


Expand Down