diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2020-01-05 17:49:35 -0700 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2020-01-05 17:58:54 -0700 |
commit | df3a4ed9c61d7e51db9f7cde5675ad8d4590135a (patch) | |
tree | e7ddfee6e155bc683195e526856a92503ca8c49c /libs/pbd | |
parent | 7570b9a594c6a6072394ea68a43433fe1466bf0f (diff) |
move call to xmlKeepBlanksDefault(0) to before the creation of an XML parser context
the value is used by the parser context; the old code called it only after the *first* parser context
was created. therefore the first XMLTree::read() call has its behavior determined by libxml2's default
for this value, rather than by our explicit choice (do not treat whitespace as a note). All subequent
read() calls will use our value.
This variable inside libxml2 is actually per-thread, which just increases the stakes for calling
xmlKeepBlanksDefault() at the right time
Diffstat (limited to 'libs/pbd')
-rw-r--r-- | libs/pbd/xml++.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libs/pbd/xml++.cc b/libs/pbd/xml++.cc index 95fb370b04..598a7684b3 100644 --- a/libs/pbd/xml++.cc +++ b/libs/pbd/xml++.cc @@ -85,13 +85,17 @@ XMLTree::read_internal(bool validate) _doc = 0; } + /* Calling this prevents libxml2 from treating whitespace as active + nodes. It needs to be called before we create a parser context. + */ + xmlKeepBlanksDefault(0); + /* create a parser context */ xmlParserCtxtPtr ctxt = xmlNewParserCtxt(); if (ctxt == NULL) { return false; } - xmlKeepBlanksDefault(0); /* parse the file, activating the DTD validation option */ if (validate) { _doc = xmlCtxtReadFile(ctxt, _filename.c_str(), NULL, XML_PARSE_DTDVALID); |