Skip to content

Commit ae91b69

Browse files
authored
Allow to set empty content to node and remove deprecated api usage (#612)
IB-8164 Signed-off-by: Raul Metsma <raul@metsma.ee>
1 parent 79d7001 commit ae91b69

2 files changed

Lines changed: 5 additions & 9 deletions

File tree

src/Container.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ void digidoc::initialize(const string &appInfo, const string &userAgent, initCal
104104
m_userAgent = userAgent;
105105

106106
LIBXML_TEST_VERSION
107-
xmlLineNumbersDefaultValue = 1;
108-
xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
109-
xmlSubstituteEntitiesDefault(1);
110-
xmlIndentTreeOutput = 1;
111107
if(xmlSecInit() < 0)
112108
THROW("Error during initialisation of xmlsec.");
113109
if(xmlSecCheckVersion() != 1)

src/XMLDocument.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,9 @@ struct XMLNode: public XMLElem<xmlNode>
252252

253253
XMLNode& operator=(sv text) noexcept
254254
{
255-
if(!d || text.empty())
255+
if(!d)
256256
return *this;
257-
xmlChar *content = xmlEncodeSpecialChars(d->doc, pcxmlChar(text.data()));
258-
xmlNodeSetContent(d, content);
259-
xmlFree(content);
257+
xmlNodeSetContent(d, pcxmlChar(text.data()));
260258
return *this;
261259
}
262260

@@ -325,8 +323,10 @@ struct XMLDocument: public unique_xml_t<decltype(xmlFreeDoc)>, public XMLNode
325323
return is->good() || is->eof() ? int(is->gcount()) : -1;
326324
}, nullptr, &is, XML_CHAR_ENCODING_NONE), xmlFreeParserCtxt);
327325
ctxt->linenumbers = 1;
326+
ctxt->options |= XML_PARSE_NOENT|XML_PARSE_DTDLOAD|XML_PARSE_DTDATTR|XML_PARSE_NONET;
327+
ctxt->loadsubset |= XML_DETECT_IDS|XML_COMPLETE_ATTRS;
328328
if(hugeFile)
329-
ctxt->options = XML_PARSE_HUGE;
329+
ctxt->options |= XML_PARSE_HUGE;
330330
auto result = xmlParseDocument(ctxt.get());
331331
if(result != 0 || !ctxt->wellFormed)
332332
THROW("%s", ctxt->lastError.message);

0 commit comments

Comments
 (0)