diff options
| author | John MacFarlane <[email protected]> | 2025-09-04 13:32:05 +0200 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2025-09-04 13:32:05 +0200 |
| commit | 226f765e762dba2c0ba60e98998cfab2a9e6d2b0 (patch) | |
| tree | 75ee3acf3c2b0f56d904c0ceadd78384d777dfcd /src | |
| parent | ad77315d2287d29dacc879b07750346f7e576a16 (diff) | |
Revision of query/fragment dropping fix to #11021.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/SelfContained.hs | 33 |
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 |
