mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-21 23:15:52 +00:00
Text.Pandoc.XML.Light: fix escaping of repeated ]]> in CDATA.
escCData stopped processing after the first "]]>" occurrence, emitting the rest of the text verbatim; a second "]]>" would prematurely terminate the CDATA section, producing invalid XML. (The original xml-light code recurses after each occurrence; the recursion was lost in the Text port.) Rewritten with T.breakOn, which also avoids building the output one character at a time. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude
parent
ef442564af
commit
f6352e497c
@@ -173,13 +173,12 @@ showCDataS cd =
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
escCData :: Text -> Builder
|
||||
escCData t
|
||||
| "]]>" `T.isPrefixOf` t =
|
||||
fromText "]]]]><![CDATA[>" <> fromText (T.drop 3 t)
|
||||
escCData t
|
||||
= case T.uncons t of
|
||||
Nothing -> mempty
|
||||
Just (c,t') -> singleton c <> escCData t'
|
||||
escCData t =
|
||||
case T.breakOn "]]>" t of
|
||||
(chunk, rest)
|
||||
| T.null rest -> fromText chunk
|
||||
| otherwise -> fromText chunk <> fromText "]]]]><![CDATA[>" <>
|
||||
escCData (T.drop 3 rest)
|
||||
|
||||
escChar :: Char -> Builder
|
||||
escChar c = case c of
|
||||
|
||||
Reference in New Issue
Block a user