From 9b2f645e2adbdc61bfd626e4ce828cb072f29f71 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 1 May 2015 22:14:50 -0700 Subject: SelfContained: cssURLs no longer tries to fetch fragment URLs. The current test is: does the URL start with a `#`? Closes #2121. --- src/Text/Pandoc/SelfContained.hs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/SelfContained.hs b/src/Text/Pandoc/SelfContained.hs index fab4c23d1..8c5fc617a 100644 --- a/src/Text/Pandoc/SelfContained.hs +++ b/src/Text/Pandoc/SelfContained.hs @@ -97,18 +97,22 @@ cssURLs media sourceURL d orig = (x,y) | B.null y -> return orig | otherwise -> do let (u,v) = B.breakSubstring ")" $ B.drop 4 y + rest <- cssURLs media sourceURL d v let url = toString $ case B.take 1 u of "\"" -> B.takeWhile (/='"') $ B.drop 1 u "'" -> B.takeWhile (/='\'') $ B.drop 1 u _ -> u - let url' = if isURI url - then url - else d url - (raw, mime) <- getRaw media sourceURL "" url' - rest <- cssURLs media sourceURL d v - let enc = fromString $ makeDataURI mime raw - return $ x `B.append` "url(" `B.append` enc `B.append` rest + case url of + '#':_ -> return $ x `B.append` rest + _ -> do + let url' = if isURI url + then url + else d url + (raw, mime) <- getRaw media sourceURL "" url' + let enc = fromString $ makeDataURI mime raw + return $ x `B.append` "url(" `B.append` enc + `B.append` rest getRaw :: MediaBag -> Maybe String -> MimeType -> String -> IO (ByteString, MimeType) -- cgit v1.2.3