From 76a6f03cb938539f33842cb17cfd29f67e44d9e8 Mon Sep 17 00:00:00 2001 From: amesgen Date: Sun, 12 Jan 2025 19:42:18 +0100 Subject: [PATCH] Don't patch out network --- cabal.project | 17 +++++++++-------- pandoc.cabal | 8 +++++++- src/Text/Pandoc/Class/IO.hs | 14 ++++++++++---- src/Text/Pandoc/Class/PandocMonad.hs | 2 -- src/Text/Pandoc/Error.hs | 9 --------- src/Text/Pandoc/SelfContained.hs | 3 --- 6 files changed, 26 insertions(+), 27 deletions(-) diff --git a/cabal.project b/cabal.project index 113efdc1375b..247f62cabd45 100644 --- a/cabal.project +++ b/cabal.project @@ -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 @@ -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 @@ -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 diff --git a/pandoc.cabal b/pandoc.cabal index 66b0082e8253..1a56949983a5 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -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, @@ -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, @@ -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 diff --git a/src/Text/Pandoc/Class/IO.hs b/src/Text/Pandoc/Class/IO.hs index 5cb7bb324593..2d337d942779 100644 --- a/src/Text/Pandoc/Class/IO.hs +++ b/src/Text/Pandoc/Class/IO.hs @@ -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) @@ -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 @@ -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 @@ -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. diff --git a/src/Text/Pandoc/Class/PandocMonad.hs b/src/Text/Pandoc/Class/PandocMonad.hs index 2db852d1fa3a..c13b3df217d9 100644 --- a/src/Text/Pandoc/Class/PandocMonad.hs +++ b/src/Text/Pandoc/Class/PandocMonad.hs @@ -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 diff --git a/src/Text/Pandoc/Error.hs b/src/Text/Pandoc/Error.hs index 415d231f8de4..30a45c0c518c 100644 --- a/src/Text/Pandoc/Error.hs +++ b/src/Text/Pandoc/Error.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/Text/Pandoc/SelfContained.hs b/src/Text/Pandoc/SelfContained.hs index 45d70427512d..25b9a960979d 100644 --- a/src/Text/Pandoc/SelfContained.hs +++ b/src/Text/Pandoc/SelfContained.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE LambdaCase #-} @@ -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