fix: Escape CDATA special char on xblock serialize (#33239)
This fixes a bug in xblock serialization when trying to copy a unit/component that contains an HTML xblock with the characters "]]>" which is a special character in CDATA.
This commit is contained in:
@@ -112,7 +112,10 @@ class XBlockSerializer:
|
||||
olx_node.attrib["editor"] = block.editor
|
||||
if block.use_latex_compiler:
|
||||
olx_node.attrib["use_latex_compiler"] = "true"
|
||||
olx_node.text = etree.CDATA("\n" + block.data + "\n")
|
||||
|
||||
# Escape any CDATA special chars
|
||||
escaped_block_data = block.data.replace("]]>", "]]>")
|
||||
olx_node.text = etree.CDATA("\n" + escaped_block_data + "\n")
|
||||
return olx_node
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user