Skip to content

Commit

Permalink
Text.Pandoc.Parsing.uri: allow & and = as word characters.
Browse files Browse the repository at this point in the history
This fixes a bug where pandoc would stop parsing a URI with an
empty attribute:  for example, `&a=&b=` wolud stop at `a`.
(The uri parser tries to guess which punctuation characters
are part of the URI and which might be punctuation after it.)

Closes #4068.
  • Loading branch information
jgm committed Nov 15, 2017
1 parent 22d69c8 commit 508aab0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Text/Pandoc/Parsing.hs
Expand Up @@ -563,7 +563,7 @@ uri = try $ do
-- http://en.wikipedia.org/wiki/State_of_emergency_(disambiguation)
-- as a URL, while NOT picking up the closing paren in
-- (http://wikipedia.org). So we include balanced parens in the URL.
let isWordChar c = isAlphaNum c || c `elem` "#$%*+/@\\_-"
let isWordChar c = isAlphaNum c || c `elem` "#$%*+/@\\_-&="
let wordChar = satisfy isWordChar
let percentEscaped = try $ char '%' >> skipMany1 (satisfy isHexDigit)
let entity = () <$ characterReference
Expand Down
9 changes: 9 additions & 0 deletions test/command/4068.md
@@ -0,0 +1,9 @@
```
pandoc -f mediawiki -t native
[https://domain.com/script.php?a=1&b=2&c=&d=4 open productname bugs]
[http://domain.com?a=. open productname bugs]
^D
[Para [Link ("",[],[]) [Str "open",Space,Str "productname",Space,Str "bugs"] ("https://domain.com/script.php?a=1&b=2&c=&d=4","")]
,Para [Str "[",Link ("",[],[]) [Str "http://domain.com?a="] ("http://domain.com?a=",""),Str ".",Space,Str "open",Space,Str "productname",Space,Str "bugs]"]]
```

0 comments on commit 508aab0

Please sign in to comment.