git.iko.soy/typeable/pandoc
on master help sign in
Textile reader: don't allow block HTML tags in inline contexts.

The reader previously did allow this, following redcloth, which happily parses Html blocks can be <div>inlined</div> as well. as <p>Html blocks can be <div>inlined</div> as well.</p> This is invalid HTML, and this kind of thing can lead to parsing problems (stack overflows) as well. So this commit undoes this behavior. The above sample now produces; <p>Html blocks can be</p> <div> <p>inlined</p> </div> <p>as well.</p>

commit97c9691696744a6e56a28dea0221e6230b029ce4 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 2 Jan 2016, 22:28 (11 years ago) parent90a2df3
3 files changed+8−10
src/Text/Pandoc/Readers/Textile.hs+2−2 tests/textile-reader.native+5−4 tests/textile-reader.textile+1−4
src/Text/Pandoc/Readers/Textile.hs+2−2
@@ -57,7 +57,7 @@ import Text.Pandoc.Builder (Inlines, Blocks, trimInlines)
5757import qualified Text.Pandoc.Builder as B
5858import Text.Pandoc.Options
5959import Text.Pandoc.Parsing
60−import Text.Pandoc.Readers.HTML ( htmlTag, isBlockTag )
60+import Text.Pandoc.Readers.HTML ( htmlTag, isBlockTag, isInlineTag )
6161import Text.Pandoc.Shared (trim)
6262import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXBlock )
6363import Text.HTML.TagSoup (parseTags, innerText, fromAttrib, Tag(..))
@@ -504,7 +504,7 @@ endline = try $ do
504504 return B.linebreak
505505
506506rawHtmlInline :: Parser [Char] ParserState Inlines
507−rawHtmlInline = B.rawInline "html" . snd <$> htmlTag (const True)
507+rawHtmlInline = B.rawInline "html" . snd <$> htmlTag isInlineTag
508508
509509-- | Raw LaTeX Inline
510510rawLaTeXInline' :: Parser [Char] ParserState Inlines
tests/textile-reader.native+5−4
@@ -150,10 +150,11 @@ Pandoc (Meta {unMeta = fromList []})
150150,RawBlock (Format "html") "<div class=\"foobar\">"
151151,Para [Str "any",Space,Strong [Str "Raw",Space,Str "HTML",Space,Str "Block"],Space,Str "with",Space,Str "bold"]
152152,RawBlock (Format "html") "</div>"
153−,Para [Str "Html",Space,Str "blocks",Space,Str "can",Space,Str "be",Space,RawInline (Format "html") "<div>",Str "inlined",RawInline (Format "html") "</div>",Space,Str "as",Space,Str "well."]
154−,BulletList
155− [[Plain [Str "this",Space,RawInline (Format "html") "<div>",Space,Str "won't",Space,Str "produce",Space,Str "raw",Space,Str "html",Space,Str "blocks",Space,RawInline (Format "html") "</div>"]]
156− ,[Plain [Str "but",Space,Str "this",Space,RawInline (Format "html") "<strong>",Space,Str "will",Space,Str "produce",Space,Str "inline",Space,Str "html",Space,RawInline (Format "html") "</strong>"]]]
153+,Para [Str "Html",Space,Str "blocks",Space,Str "can"]
154+,RawBlock (Format "html") "<div>"
155+,Para [Str "interrupt",Space,Str "paragraphs"]
156+,RawBlock (Format "html") "</div>"
157+,Para [Str "as",Space,Str "well."]
157158,Para [Str "Can",Space,Str "you",Space,Str "prove",Space,Str "that",Space,Str "2",Space,Str "<",Space,Str "3",Space,Str "?"]
158159,Header 1 ("acronyms-and-marks",[],[]) [Str "Acronyms",Space,Str "and",Space,Str "marks"]
159160,Para [Str "PBS (Public Broadcasting System)"]
tests/textile-reader.textile+1−4
@@ -228,10 +228,7 @@ However, <strong> raw HTML inlines </strong> are accepted, as well as :
228228 any *Raw HTML Block* with bold
229229</div>
230230
231−Html blocks can be <div>inlined</div> as well.
232−
233−* this <div> won't produce raw html blocks </div>
234−* but this <strong> will produce inline html </strong>
231+Html blocks can <div>interrupt paragraphs</div> as well.
235232
236233Can you prove that 2 < 3 ?
237234