From 112f963fb12a941762c828dfd1690a61771516af Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 30 Apr 2017 19:06:29 +0200 Subject: Relax any hardcoded limit from the libxml2 parser when creating documents from memory This fixes many bugs (mostly caused by very long image data URIs) Fixed bugs: - https://launchpad.net/bugs/1572280 - https://launchpad.net/bugs/1412912 - https://launchpad.net/bugs/1373322 - https://launchpad.net/bugs/1243011 - https://launchpad.net/bugs/1627004 - https://launchpad.net/bugs/1627004 (bzr r15654) --- src/xml/repr-io.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/xml') diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index ae6f238d4..d8e0f5418 100644 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@ -404,7 +404,12 @@ Document *sp_repr_read_mem (const gchar * buffer, gint length, const gchar *defa g_return_val_if_fail (buffer != NULL, NULL); - doc = xmlParseMemory (const_cast(buffer), length); + int parser_options = XML_PARSE_HUGE | XML_PARSE_RECOVER; + parser_options |= XML_PARSE_NONET; // TODO: should we allow network access? + // proper solution would be to check the preference "/options/externalresources/xml/allow_net_access" + // as done in XmlSource::readXml which gets called by the analogous sp_repr_read_file() + // but sp_repr_read_mem() seems to be called in locations where Inkscape::Preferences::get() fails badly + doc = xmlReadMemory (const_cast(buffer), length, NULL, NULL, parser_options); rdoc = sp_repr_do_read (doc, default_ns); if (doc) { -- cgit v1.2.3