Author: ict <ict@kampertnauta.nl>
Date:   Tue Dec 10 09:59:04 2013 +0100

    Added flag support for HUGE xml files

diff --git a/rsvg-base.c b/rsvg-base.c
index cb9f64a..fd3c49c 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -574,6 +574,8 @@ rsvg_start_xinclude (RsvgHandle * ctx, RsvgPropertyBag * atts)

         xml_parser = xmlCreatePushParserCtxt (&rsvgSAXHandlerStruct, ctx, NULL, 0, NULL);
         xml_parser->options |= XML_PARSE_NONET;
+        if (ctx->priv->flags & RSVG_HANDLE_FLAGS_HUGE)
+            xml_parser->options |= XML_PARSE_HUGE;

         buffer = _rsvg_xml_input_buffer_new_from_stream (stream, NULL /* cancellable */, XML_CHAR_ENCODING_NONE, &err);
         g_object_unref (stream);
@@ -1114,6 +1116,8 @@ rsvg_handle_write_impl (RsvgHandle * handle, const guchar * buf, gsize count, GE
         handle->priv->ctxt = xmlCreatePushParserCtxt (&rsvgSAXHandlerStruct, handle, NULL, 0,
                                                       rsvg_handle_get_base_uri (handle));
         handle->priv->ctxt->options |= XML_PARSE_NONET;
+        if (handle->priv->flags & RSVG_HANDLE_FLAGS_HUGE)
+            handle->priv->ctxt->options |= XML_PARSE_HUGE;

         /* if false, external entities work, but internal ones don't. if true, internal entities
            work, but external ones don't. favor internal entities, in order to not cause a
@@ -1771,6 +1775,8 @@ rsvg_handle_read_stream_sync (RsvgHandle   *handle,
         priv->ctxt = xmlCreatePushParserCtxt (&rsvgSAXHandlerStruct, handle, NULL, 0,
                                               rsvg_handle_get_base_uri (handle));
         priv->ctxt->options |= XML_PARSE_NONET;
+        if (priv->flags & RSVG_HANDLE_FLAGS_HUGE)
+            priv->ctxt->options |= XML_PARSE_HUGE;

         /* if false, external entities work, but internal ones don't. if true, internal entities
            work, but external ones don't. favor internal entities, in order to not cause a
diff --git a/rsvg.h b/rsvg.h
index f460146..d33c4da 100644
--- a/rsvg.h
+++ b/rsvg.h
@@ -143,7 +143,8 @@ gboolean rsvg_handle_has_sub (RsvgHandle * handle, const char *id);

 typedef enum /*< flags >*/
 {
-    RSVG_HANDLE_FLAGS_NONE        = 0
+    RSVG_HANDLE_FLAGS_NONE        = 0,
+    RSVG_HANDLE_FLAGS_HUGE        = 1
 } RsvgHandleFlags;

 RsvgHandle *rsvg_handle_new_with_flags (RsvgHandleFlags flags);