aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2025-09-04 13:32:05 +0200
committerJohn MacFarlane <[email protected]>2025-09-04 13:32:05 +0200
commit226f765e762dba2c0ba60e98998cfab2a9e6d2b0 (patch)
tree75ee3acf3c2b0f56d904c0ceadd78384d777dfcd /src/Text
parentad77315d2287d29dacc879b07750346f7e576a16 (diff)
Revision of query/fragment dropping fix to #11021.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/SelfContained.hs33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/Text/Pandoc/SelfContained.hs b/src/Text/Pandoc/SelfContained.hs
index e4126171f..330dddff2 100644
--- a/src/Text/Pandoc/SelfContained.hs
+++ b/src/Text/Pandoc/SelfContained.hs
@@ -43,7 +43,6 @@ import Data.Either (lefts, rights)
import Data.Maybe (isNothing)
import qualified Data.Map as M
import Control.Monad.State
--- import Debug.Trace
isOk :: Char -> Bool
isOk c = isAscii c && isAlphaNum c
@@ -420,25 +419,23 @@ getData mimetype src
return res
else return raw'
return $ Fetched (mime, result)
- handler e = case e of
- PandocResourceNotFound r -> do
- -- If fetch failed and we have a fragment and/or query,
- -- try the fetch again without these, since the resource
- -- may be local (see #1477, #11021)
- if T.any (\c -> c == '?' || c == '#') src && not (isURI src)
- then getData mimetype (removeQueryAndFragment src)
- else do
- report $ CouldNotFetchResource r ""
- return $ CouldNotFetch e
- PandocHttpError u er -> do
- report $ CouldNotFetchResource u (tshow er)
- return $ CouldNotFetch e
- _ -> throwError e
+ handler e
+ -- If fetch failed and we have a fragment and/or query,
+ -- try the fetch again without these, since the resource
+ -- may be local (see #1477, #11021)
+ | T.any (\c -> c == '?' || c == '#') src && not (isURI src)
+ = getData mimetype (removeQueryAndFragment src)
+ | otherwise
+ = case e of
+ PandocResourceNotFound r -> do
+ report $ CouldNotFetchResource r ""
+ return $ CouldNotFetch e
+ PandocHttpError u er -> do
+ report $ CouldNotFetchResource u (tshow er)
+ return $ CouldNotFetch e
+ _ -> throwError e
removeQueryAndFragment = T.takeWhile (\c -> c /= '#' && c /= '?')
-
-
-
-- | Convert HTML into self-contained HTML, incorporating images,
-- scripts, and CSS using data: URIs.
makeSelfContained :: PandocMonad m => T.Text -> m T.Text