[libgsf] xlsx: fix problem with absolute relation targets.



commit 9fb23e1171f48d7dbf788e95cf61519ec46e479a
Author: Morten Welinder <terra gnome org>
Date:   Wed Jun 17 13:33:42 2015 -0400

    xlsx: fix problem with absolute relation targets.

 ChangeLog                |    5 +++++
 NEWS                     |    1 +
 gsf/gsf-open-pkg-utils.c |   18 +++++++++++++++++-
 3 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 11fd92c..4eb88b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-17  Morten Welinder  <terra gnome org>
+
+       * gsf/gsf-open-pkg-utils.c (gsf_open_pkg_open_rel): Improve
+       handling of absolute references.  Fixes #751120.
+
 2015-06-11  Morten Welinder  <terra gnome org>
 
        * gsf/gsf-msole-utils.c (msole_prop_read): Fuzzed file fix.
diff --git a/NEWS b/NEWS
index e6ce7dc..e4c5779 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ libgsf 1.14.34
 Morten:
        * Fix OLE2 property parsing problem.  [#748528]
        * Fuzzed file fixes.  [#749120] [#749169] [#749183] [#750809]
+       * xlsx: fix problem with absolute relation targets.  [#751120]
 
 --------------------------------------------------------------------------
 libgsf 1.14.33
diff --git a/gsf/gsf-open-pkg-utils.c b/gsf/gsf-open-pkg-utils.c
index c0fbcd5..3cfb76f 100644
--- a/gsf/gsf-open-pkg-utils.c
+++ b/gsf/gsf-open-pkg-utils.c
@@ -223,6 +223,7 @@ gsf_open_pkg_open_rel (GsfInput *opkg, GsfOpenPkgRel const *rel,
        GsfInfile *parent, *prev_parent;
        gchar **elems;
        unsigned i;
+       const char *target;
 
        g_return_val_if_fail (rel != NULL, NULL);
        g_return_val_if_fail (opkg != NULL, NULL);
@@ -230,9 +231,24 @@ gsf_open_pkg_open_rel (GsfInput *opkg, GsfOpenPkgRel const *rel,
        /* References from the root use children of opkg
         * References from a child are relative to siblings of opkg */
        parent = gsf_input_name (opkg)
-               ? gsf_input_container (opkg) : GSF_INFILE (opkg);
+               ? gsf_input_container (opkg)
+               : GSF_INFILE (opkg);
        g_object_ref (parent);
 
+       target = rel->target;
+       if (target[0] == '/') {
+               target++;
+               /* Handle absolute references by going as far up as we can.  */
+               while (1) {
+                       GsfInfile *next_parent = gsf_input_container (GSF_INPUT (parent));
+                       if (next_parent &&
+                           G_OBJECT_TYPE (next_parent) == G_OBJECT_TYPE (parent))
+                               parent = next_parent;
+                       else
+                               break;
+               }
+       }
+
        elems = g_strsplit (rel->target, "/", 0);
        for (i = 0 ; elems[i] && NULL != parent ; i++) {
                if (0 == strcmp (elems[i], ".") || '\0' == *elems[i])


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]