[glabels/glabels_2_2] Relax libxml limits when parsing label files
- From: Jim Evins <jimevins src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glabels/glabels_2_2] Relax libxml limits when parsing label files
- Date: Sun, 7 Feb 2010 01:29:48 +0000 (UTC)
commit 01b54d65f1bc32538314f01cbe89d89b2d0baa77
Author: Jim Evins <evins snaught com>
Date: Sat Feb 6 20:21:26 2010 -0500
Relax libxml limits when parsing label files
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 | 9 +++++++++
src/Makefile.am | 1 +
src/xml-label.c | 10 +++++++++-
3 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/configure.in b/configure.in
index 12c9cd3..1d11adc 100644
--- a/configure.in
+++ b/configure.in
@@ -130,6 +130,15 @@ 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 ---------------------------------------------------------------------------
AC_ARG_ENABLE(deprecations,
diff --git a/src/Makefile.am b/src/Makefile.am
index d687e1b..aea2482 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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)"\" \
diff --git a/src/xml-label.c b/src/xml-label.c
index 5a56d8c..07452b2 100644
--- a/src/xml-label.c
+++ b/src/xml-label.c
@@ -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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]