]> git.sur5r.net Git - glabels/commitdiff
Relax libxml limits when parsing label files
authorJim Evins <evins@snaught.com>
Sun, 7 Feb 2010 01:21:26 +0000 (20:21 -0500)
committerJim Evins <evins@snaught.com>
Sun, 7 Feb 2010 01:21:26 +0000 (20:21 -0500)
Glabels bug #2940758.  Back port from master:  Use XML_PARSE_HUGE parser option
so that we can handle large text nodes, such as encoded images.  This
modification is only applied if libxml 2.7+ is available, as to not introduce
new dependencies.

configure.in
src/Makefile.am
src/xml-label.c

index 12c9cd344e17ad36f780af6fda46d5045eb11dc9..1d11adc84b4be5facacb7c6e5155e88e53c15c7f 100644 (file)
@@ -129,6 +129,15 @@ AC_SUBST(MYGAL_CFLAGS)
 AC_SUBST(MYGAL_LIBS)
 
 
+dnl ---------------------------------------------------------------------------
+dnl - Is XML_PARSE_HUGE available?
+dnl ---------------------------------------------------------------------------
+PKG_CHECK_MODULES(XML_PARSE_HUGE, libxml-2.0 >= 2.7.0,
+                  HAVE_XML_PARSE_HUGE="-DHAVE_XML_PARSE_HUGE",
+                  HAVE_XML_PARSE_HUGE="-UHAVE_XML_PARSE_HUGE")
+AC_SUBST(HAVE_XML_PARSE_HUGE)
+
+
 dnl ---------------------------------------------------------------------------
 dnl - Enable deprecation testing
 dnl ---------------------------------------------------------------------------
index d687e1ba8e2183142e080b914678b7155a30467f..aea24826ab975656550d5304870edb8c9ee9686f 100644 (file)
@@ -11,6 +11,7 @@ INCLUDES = \
        -I$(LIB_BARCODE_DIR)                                    \
        -I$(LIB_IEC16022_DIR)                                   \
        $(GLABELS_CFLAGS)                                       \
+       $(HAVE_XML_PARSE_HUGE)                                  \
        $(DISABLE_DEPRECATED_CFLAGS)                            \
        -DPREFIX=\""$(prefix)"\"                                \
        -DSYSCONFDIR=\""$(sysconfdir)"\"                        \
index 5a56d8cd77591a6152c11a5c9ffa6648e00ed561..07452b250a9ac37d96d6a1451f60411a611e4be0 100644 (file)
@@ -184,7 +184,11 @@ gl_xml_label_open (const gchar      *utf8_filename,
        filename = g_filename_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
        g_return_val_if_fail (filename, NULL);
 
+#ifndef HAVE_XML_PARSE_HUGE
        doc = xmlParseFile (filename);
+#else
+        doc = xmlReadFile (filename, NULL, XML_PARSE_HUGE);
+#endif
        if (!doc) {
                g_message (_("xmlParseFile error"));
                *status = XML_LABEL_ERROR_OPEN_PARSE;
@@ -221,9 +225,13 @@ gl_xml_label_open_buffer (const gchar      *buffer,
 
        gl_debug (DEBUG_XML, "START");
 
+#ifndef HAVE_XML_PARSE_HUGE
        doc = xmlParseDoc ((xmlChar *) buffer);
+#else
+        doc = xmlReadDoc ((xmlChar *) buffer, NULL, NULL, XML_PARSE_HUGE);
+#endif
        if (!doc) {
-               g_message (_("xmlParseFile error"));
+               g_message (_("xmlParseDoc error"));
                *status = XML_LABEL_ERROR_OPEN_PARSE;
                return NULL;
        }