SelfContained: cssURLs no longer tries to fetch fragment URLs.

The current test is: does the URL start with a `#`?
Closes #2121.
This commit is contained in:
John MacFarlane
2015-05-01 22:15:43 -07:00
parent 4b2f469994
commit 9b2f645e2a
+11 -7
View File
@@ -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)