git.iko.soy/typeable/pandoc
on master help sign in
Parsing: Fixed uri -- escape unicode URLs.

Otherwise Network.URI.parseURI fails on e.g. Chinese URLs. Changed an incorrect test in markdown-reader-more.

commit51e0bd277a736fe7d11e456a17ff7995b71db60e authorJohn MacFarlane <jgm@berkeley.edu> dateMon 14 Jan 2013, 17:38 (14 years ago) parent0ef24d1
2 files changed+3−3
src/Text/Pandoc/Parsing.hs+2−2 tests/markdown-reader-more.native+1−1
src/Text/Pandoc/Parsing.hs+2−2
@@ -153,7 +153,7 @@ import Text.Parsec
153153import Text.Parsec.Pos (newPos)
154154import Data.Char ( toLower, toUpper, ord, isAscii, isAlphaNum, isDigit, isPunctuation )
155155import Data.List ( intercalate, transpose )
156−import Network.URI ( parseURI, URI (..), isAllowedInURI )
156+import Network.URI ( parseURI, URI (..), isAllowedInURI, isUnescapedInURI, escapeURIString )
157157import Text.Pandoc.Shared
158158import qualified Data.Map as M
159159import Text.TeXMath.Macros (applyMacros, Macro, parseMacroDefinitions)
@@ -380,7 +380,7 @@ uri = try $ do
380380 str <- liftM concat $ many1 $ inParens <|> count 1 (innerPunct <|> uriChar)
381381 str' <- option str $ char '/' >> return (str ++ "/")
382382 -- now see if they amount to an absolute URI
383− case parseURI (escapeURI str') of
383+ case parseURI (escapeURIString isUnescapedInURI str') of
384384 Just uri' -> if uriScheme uri' `elem` protocols
385385 then return (str', show uri')
386386 else fail "not a URI"
tests/markdown-reader-more.native+1−1
@@ -29,7 +29,7 @@
2929,Para [Str "`hi"]
3030,Para [Str "there`"]
3131,Header 2 ("multilingual-urls",[],[]) [Str "Multilingual",Space,Str "URLs"]
32−,Para [RawInline "html" "<http://\27979.com?\27979=\27979>"]
32+,Para [Link [Str "http://\27979.com?\27979=\27979"] ("http://%E6%B5%8B.com?%E6%B5%8B=%E6%B5%8B","")]
3333,Para [Link [Str "foo"] ("/bar/\27979?x=\27979","title")]
3434,Para [Link [Str "\27979@foo.\27979.baz"] ("mailto:\27979@foo.\27979.baz","")]
3535,Header 2 ("numbered-examples",[],[]) [Str "Numbered",Space,Str "examples"]