[goffice] Fix color maps loading. [#735007]



commit 18fdbaa5838e8ec7b28e1f91ac0bb6cec3737373
Author: Jean Brefort <jean brefort normalesup org>
Date:   Tue Aug 19 16:09:03 2014 +0200

    Fix color maps loading. [#735007]

 ChangeLog                          |    6 ++++++
 NEWS                               |    1 +
 goffice/graph/gog-axis-color-map.c |   10 ++++++----
 3 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index bf9d5bd..a8a93c2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-08-19  Jean Brefort  <jean brefort normalesup org>
+
+       * goffice/graph/gog-axis-color-map.c (gog_axis_color_map_save): better
+       file mode, (color_maps_load_from_dir): don't check the mime type as it
+       seems not so reliable, just check the extension. [#735007]
+
 2014-08-18  Jean Brefort  <jean brefort normalesup org>
 
        * goffice/graph/gog-axis-color-map.c (gog_axis_color_map_save): create
diff --git a/NEWS b/NEWS
index 6a62ffc..ed41452 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ Jean:
        * Fix default ticks position.
        * Fix font color theme support. [Debian 757611]
        * Fix saving color maps when directory does not exists. [#735008]
+       * Fix color maps loading. [#735007]
 
 Morten:
        * Work around gtk+ ABI break for colour selector.  [#733350]
diff --git a/goffice/graph/gog-axis-color-map.c b/goffice/graph/gog-axis-color-map.c
index 8c0ac69..d27cb57 100644
--- a/goffice/graph/gog-axis-color-map.c
+++ b/goffice/graph/gog-axis-color-map.c
@@ -307,7 +307,7 @@ gog_axis_color_map_save (GogAxisColorMap const *map)
        GsfXMLOut *xml;
        if (output == NULL) {
                char *dir = go_dirname_from_uri (map->uri, TRUE);
-               int res = g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | 
S_IROTH | S_IXOTH);
+               int res = g_mkdir_with_parents (dir, 0777);
                g_free (dir);
                if (res < 0) {
                        g_warning ("[GogAxisColorMap]: Could not save color map to %s", map->uri);
@@ -947,10 +947,12 @@ color_maps_load_from_dir (char const *path)
        while ((d_name = g_dir_read_name (dir)) != NULL) {
                char *fullname = g_build_filename (path, d_name, NULL);
                char *uri = go_filename_to_uri (fullname);
-               char *mime_type = go_get_mime_type (uri);
-               if (!strcmp (mime_type, "application/xml")) /* we don't have a better one */
+               size_t n = strlen (uri);
+                /* checking for mime type does not look safe, so we check for the
+                extension. TRhings might fail later if the file does not describe a
+                valid color map */
+               if (n >= 4 && !strcmp (uri + n - 4, ".map"))
                        color_map_load_from_uri (uri);
-               g_free (mime_type);
                g_free (uri);
                g_free (fullname);
        }


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