aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-06-09 12:11:22 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-06-09 12:11:22 -0700
commitedb0bcc04f330042a7b7f73e2806c534b9869e62 (patch)
tree365bd462e2c392b7874a62d313f9a9738d21d8c0 /src
parent3e533b4f95852f3e81ef437d22236462258eb7b8 (diff)
parentf51757bd16881b6429cccb115f36d595b80826a7 (diff)
downloadpandoc-edb0bcc04f330042a7b7f73e2806c534b9869e62.tar.gz
Merge pull request #2215 from DigitalPublishingToolkit/icml-crashfix
Fix InDesign crash with URLs containing more than one colon character
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/ICML.hs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/ICML.hs b/src/Text/Pandoc/Writers/ICML.hs
index f42d26614..08e3e5b63 100644
--- a/src/Text/Pandoc/Writers/ICML.hs
+++ b/src/Text/Pandoc/Writers/ICML.hs
@@ -251,6 +251,13 @@ charStylesToDoc st = vcat $ map makeStyle $ Set.toAscList $ inlineStyles st
else empty
in inTags True "CharacterStyle" ([("Self", "CharacterStyle/"++s), ("Name", s)] ++ attrs') props
+-- | Escape colon characters as %3a
+escapeColons :: String -> String
+escapeColons (x:xs)
+ | x == ':' = "%3a" ++ escapeColons xs
+ | otherwise = x : escapeColons xs
+escapeColons [] = []
+
-- | Convert a list of (identifier, url) pairs to the ICML listing of hyperlinks.
hyperlinksToDoc :: Hyperlink -> Doc
hyperlinksToDoc [] = empty
@@ -259,13 +266,13 @@ hyperlinksToDoc (x:xs) = hyp x $$ hyperlinksToDoc xs
hyp (ident, url) = hdest $$ hlink
where
hdest = selfClosingTag "HyperlinkURLDestination"
- [("Self", "HyperlinkURLDestination/"++url), ("Name","link"), ("DestinationURL",url), ("DestinationUniqueKey","1")]
+ [("Self", "HyperlinkURLDestination/"++(escapeColons url)), ("Name","link"), ("DestinationURL",url), ("DestinationUniqueKey","1")] -- HyperlinkURLDestination with more than one colon crashes CS6
hlink = inTags True "Hyperlink" [("Self","uf-"++show ident), ("Name",url),
("Source","htss-"++show ident), ("Visible","true"), ("DestinationUniqueKey","1")]
$ inTags True "Properties" []
$ inTags False "BorderColor" [("type","enumeration")] (text "Black")
$$ (inTags False "Destination" [("type","object")]
- $ text $ "HyperlinkURLDestination/"++(escapeStringForXML url))
+ $ text $ "HyperlinkURLDestination/"++(escapeColons (escapeStringForXML url))) -- HyperlinkURLDestination with more than one colon crashes CS6
-- | Convert a list of Pandoc blocks to ICML.