git.iko.soy/typeable/pandoc
on master help sign in
Avoid parsing partial URLs as HTML tags.
99fe859John MacFarlane
src/Text/Pandoc/Readers/HTML.hs+8−1
@@ -911,8 +911,15 @@ htmlTag :: Monad m
911htmlTag f = try $ do
911htmlTag f = try $ do
912 lookAhead (char '<')
912 lookAhead (char '<')
913 inp <- getInput
913 inp <- getInput
914+ let hasTagWarning (TagWarning _:_) = True
915+ hasTagWarning _ = False
914− let (next : _) = canonicalizeTags $ parseTags inp
916+ let (next : rest) = canonicalizeTags $ parseTagsOptions
917+ parseOptions{ optTagWarning = True } inp
915 guard $ f next
918 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
916 case next of
923 case next of
917 TagComment s
924 TagComment s
918 | "<!--" `isPrefixOf` inp -> do
925 | "<!--" `isPrefixOf` inp -> do
tests/Tests/Readers/Markdown.hs+3
@@ -195,6 +195,9 @@ tests = [ testGroup "inline code"
195 [ "with unicode dash following" =:
195 [ "with unicode dash following" =:
196 "<http://foo.bar>\8212" =?> para (autolink "http://foo.bar" <>
196 "<http://foo.bar>\8212" =?> para (autolink "http://foo.bar" <>
197 str "\8212")
197 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>")
198 ]
201 ]
199 , testGroup "Headers"
202 , testGroup "Headers"
200 [ "blank line before header" =:
203 [ "blank line before header" =: