git.iko.soy/typeable/pandoc
on master help sign in
Avoid parsing partial URLs as HTML tags.

Closes #2277.

commit99fe8594d94573b8ba8ec1d1e47b57444de4e4cb authorJohn MacFarlane <jgm@berkeley.edu> dateFri 10 Jul 2015, 10:28 (11 years ago) parent5f730ee
2 files changed+11−1
src/Text/Pandoc/Readers/HTML.hs+8−1 tests/Tests/Readers/Markdown.hs+3
src/Text/Pandoc/Readers/HTML.hs+8−1
@@ -911,8 +911,15 @@ htmlTag :: Monad m
911911htmlTag f = try $ do
912912 lookAhead (char '<')
913913 inp <- getInput
914− let (next : _) = canonicalizeTags $ parseTags inp
914+ let hasTagWarning (TagWarning _:_) = True
915+ hasTagWarning _ = False
916+ let (next : rest) = canonicalizeTags $ parseTagsOptions
917+ parseOptions{ optTagWarning = True } inp
915918 guard $ f next
919+ -- we get a TagWarning on things like
920+ -- <www.boe.es/buscar/act.php?id=BOE-A-1996-8930#a66>
921+ -- which should NOT be parsed as an HTML tag, see #2277
922+ guard $ not $ hasTagWarning rest
916923 case next of
917924 TagComment s
918925 | "<!--" `isPrefixOf` inp -> do
tests/Tests/Readers/Markdown.hs+3
@@ -195,6 +195,9 @@ tests = [ testGroup "inline code"
195195 [ "with unicode dash following" =:
196196 "<http://foo.bar>\8212" =?> para (autolink "http://foo.bar" <>
197197 str "\8212")
198+ , "a partial URL (#2277)" =:
199+ "<www.boe.es/buscar/act.php?id=BOE-A-1996-8930#a66>" =?>
200+ para (text "<www.boe.es/buscar/act.php?id=BOE-A-1996-8930#a66>")
198201 ]
199202 , testGroup "Headers"
200203 [ "blank line before header" =: