aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2013-04-25 12:28:55 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2013-04-25 12:28:55 -0700
commitd776ee191e405b658793d0fa27ff8d22ee40ad7c (patch)
tree76f612edf0b4f71c4f550fb8886f4bf0432f89e1
parentfd36acf439e921848254924853e3185957c7fda4 (diff)
downloadpandoc-d776ee191e405b658793d0fa27ff8d22ee40ad7c.tar.gz
Don't convert to lowercase in email obfuscation.
Closes #839.
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index de48ef996..1e4b19184 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -338,11 +338,13 @@ footnoteSection opts notes =
-- | Parse a mailto link; return Just (name, domain) or Nothing.
parseMailto :: String -> Maybe (String, String)
-parseMailto ('m':'a':'i':'l':'t':'o':':':addr) =
- let (name', rest) = span (/='@') addr
- domain = drop 1 rest
- in Just (name', domain)
-parseMailto _ = Nothing
+parseMailto s = do
+ case break (==':') s of
+ (xs,':':addr) | map toLower xs == "mailto" -> do
+ let (name', rest) = span (/='@') addr
+ let domain = drop 1 rest
+ return (name', domain)
+ _ -> fail "not a mailto: URL"
-- | Obfuscate a "mailto:" link.
obfuscateLink :: WriterOptions -> String -> String -> Html
@@ -350,7 +352,7 @@ obfuscateLink opts txt s | writerEmailObfuscation opts == NoObfuscation =
H.a ! A.href (toValue s) $ toHtml txt
obfuscateLink opts txt s =
let meth = writerEmailObfuscation opts
- s' = map toLower s
+ s' = map toLower (take 7 s) ++ drop 7 s
in case parseMailto s' of
(Just (name', domain)) ->
let domain' = substitute "." " dot " domain