Fix XML-writer edge-case (empty content)
authorRobin Gareus <robin@gareus.org>
Fri, 1 Nov 2019 14:39:44 +0000 (15:39 +0100)
committerRobin Gareus <robin@gareus.org>
Fri, 1 Nov 2019 14:39:44 +0000 (15:39 +0100)
libs/pbd/xml++.cc

index 65488529174a1121a442418041dc0551930b7e83..95fb370b04e32a51acb17baa4189450ee4b4ae9f 100644 (file)
@@ -482,6 +482,12 @@ XMLNode::attribute_value()
 XMLNode*
 XMLNode::add_content(const string& c)
 {
+       if (c.empty ()) {
+               /* this would add a "</>" child, leading to invalid XML.
+                * Also in XML, empty string content is equivalent to no content.
+                */
+               return NULL;
+       }
        return add_child_copy(XMLNode (string(), c));
 }