git.iko.soy/typeable/pandoc
on master help sign in
Parsing: Further improvements to uri parser.
ee0fc19John MacFarlane
src/Text/Pandoc/Parsing.hs+4−2
@@ -425,7 +425,8 @@ uri = try $ do
425 -- http://en.wikipedia.org/wiki/State_of_emergency_(disambiguation)
425 -- http://en.wikipedia.org/wiki/State_of_emergency_(disambiguation)
426 -- as a URL, while NOT picking up the closing paren in
426 -- as a URL, while NOT picking up the closing paren in
427 -- (http://wikipedia.org). So we include balanced parens in the URL.
427 -- (http://wikipedia.org). So we include balanced parens in the URL.
428− let isWordChar c = isAlphaNum c || c == '_' || c == '/' || not (isAscii c)
428+ let isWordChar c = isAlphaNum c || c == '_' || c == '/' || c == '+' ||
429+ not (isAscii c)
429 let wordChar = satisfy isWordChar
430 let wordChar = satisfy isWordChar
430 let percentEscaped = try $ char '%' >> skipMany1 (satisfy isHexDigit)
431 let percentEscaped = try $ char '%' >> skipMany1 (satisfy isHexDigit)
431 let entity = () <$ characterReference
432 let entity = () <$ characterReference
@@ -434,7 +435,8 @@ uri = try $ do
434 let uriChunk = skipMany1 wordChar
435 let uriChunk = skipMany1 wordChar
435 <|> percentEscaped
436 <|> percentEscaped
436 <|> entity
437 <|> entity
438+ <|> (try $ punct >>
437− <|> (try $ punct >> lookAhead (satisfy isWordChar) >> return ())
439+ lookAhead (void (satisfy isWordChar) <|> percentEscaped))
438 str <- snd `fmap` withRaw (skipMany1 ( () <$
440 str <- snd `fmap` withRaw (skipMany1 ( () <$
439 (enclosed (char '(') (char ')') uriChunk
441 (enclosed (char '(') (char ')') uriChunk
440 <|> enclosed (char '{') (char '}') uriChunk
442 <|> enclosed (char '{') (char '}') uriChunk