[gnumeric] Fix crash on xlsx import due to external references. [#702407]



commit 982fb41987ede923d124c69d1bbf50a0e3ffaea0
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Sun Jun 16 16:34:30 2013 -0600

    Fix crash on xlsx import due to external references. [#702407]
    
    2013-06-15  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * xlsx-read.c (xlsx_read_external_book): also try an alternative url
        (xlsx_read_external_sheetname): check whether we have a book before
        adding sheets to it.

 NEWS                      |    3 ++-
 plugins/excel/ChangeLog   |    6 ++++++
 plugins/excel/xlsx-read.c |   25 ++++++++++++++++++-------
 3 files changed, 26 insertions(+), 8 deletions(-)
---
diff --git a/NEWS b/NEWS
index 50dc584..11ec24e 100644
--- a/NEWS
+++ b/NEWS
@@ -25,7 +25,8 @@ Andreas:
        * In ODF import ignored mentioned but not included sheets. [#698388]
        * Fix crash on corrupted files.  [#702205] [#702219] [#702285]
          [#702288] [#702322] [#702364] [#702409]
-       * Some documentation improvements. [Debian #621735] [Debian #530462] 
+       * Some documentation improvements. [Debian #621735] [Debian #530462]
+       * Fix crash on xlsx import due to external references. [#702407] 
 
 Darrell Tangman:
        * Update documentation for Edit and Insert menus. [#700596]
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 13e86d1..d008ac1 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,9 @@
+2013-06-15  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * xlsx-read.c (xlsx_read_external_book): also try an alternative url
+       (xlsx_read_external_sheetname): check whether we have a book before
+       adding sheets to it.
+
 2013-06-16  Morten Welinder  <terra gnome org>
 
        * xlsx-read-drawing.c (xlsx_blip_start): Handle errors in getting
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index af557fd..97f0e6b 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -3355,12 +3355,20 @@ static void
 xlsx_read_external_book (GsfXMLIn *xin, G_GNUC_UNUSED xmlChar const **attrs)
 {
        XLSXReadState *state = (XLSXReadState *)xin->user_state;
-       GsfOpenPkgRel const *rel = gsf_open_pkg_lookup_rel_by_type (
-               gsf_xml_in_get_input (xin),
-               "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath";);
+       GsfOpenPkgRel const *rel = gsf_open_pkg_lookup_rel_by_type
+               (gsf_xml_in_get_input (xin),
+                "http://schemas.openxmlformats.org/officeDocument/2006/relationships/";
+                "externalLink");
+       if (rel == NULL)
+               rel = gsf_open_pkg_lookup_rel_by_type 
+                       (gsf_xml_in_get_input (xin),
+                        "http://schemas.openxmlformats.org/officeDocument/2006/relationships/";
+                        "externalLinkPath");
        if (NULL != rel && gsf_open_pkg_rel_is_extern (rel))
                state->external_ref = xlsx_conventions_add_extern_ref (
                        state->convs, gsf_open_pkg_rel_get_target (rel));
+       else
+               xlsx_warning (xin, _("Unable to resolve external relationship"));
 }
 static void
 xlsx_read_external_book_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
@@ -3372,10 +3380,13 @@ static void
 xlsx_read_external_sheetname (GsfXMLIn *xin, xmlChar const **attrs)
 {
        XLSXReadState *state = (XLSXReadState *)xin->user_state;
-       for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
-               if (0 == strcmp (attrs[0], "val"))
-                       workbook_sheet_attach (state->external_ref,
-                               state->external_ref_sheet = sheet_new (state->external_ref, attrs[1], 256, 
65536));
+       if (state->external_ref)
+               for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
+                       if (0 == strcmp (attrs[0], "val"))
+                               workbook_sheet_attach 
+                                       (state->external_ref,
+                                        state->external_ref_sheet = 
+                                        sheet_new (state->external_ref, attrs[1], 256, 65536));
 }
 static void
 xlsx_read_external_sheetname_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)


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