Skip to content

Commit

Permalink
HTML reader: don't canonicalize data: URIs.
Browse files Browse the repository at this point in the history
It can be very expensive to call network-uri's URI parser on
these. See #10075.
  • Loading branch information
jgm committed Dec 18, 2024
1 parent 669c2b8 commit ca4ad3b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Text/Pandoc/Readers/HTML.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1222,8 +1222,10 @@ htmlTag f = try $ do

-- | Adjusts a url according to the document's base URL.
canonicalizeUrl :: PandocMonad m => Text -> TagParser m Text
canonicalizeUrl url = do
mbBaseHref <- baseHref <$> getState
return $ case (parseURIReference (T.unpack url), mbBaseHref) of
(Just rel, Just bs) -> tshow (rel `nonStrictRelativeTo` bs)
_ -> url
canonicalizeUrl url
| "data:" `T.isPrefixOf` url = return url
| otherwise = do
mbBaseHref <- baseHref <$> getState
return $ case (parseURIReference (T.unpack url), mbBaseHref) of
(Just rel, Just bs) -> tshow (rel `nonStrictRelativeTo` bs)
_ -> url

0 comments on commit ca4ad3b

Please sign in to comment.