[Goodies-commits] r2566 - in xfce4-places-plugin/trunk: . panel-plugin
Diego Ongaro
ongardie at xfce.org
Sun Mar 25 08:31:29 CEST 2007
Author: ongardie
Date: 2007-03-25 06:31:29 +0000 (Sun, 25 Mar 2007)
New Revision: 2566
Added:
xfce4-places-plugin/trunk/panel-plugin/unescape_uri.c
Modified:
xfce4-places-plugin/trunk/ChangeLog
xfce4-places-plugin/trunk/panel-plugin/Makefile.am
xfce4-places-plugin/trunk/panel-plugin/places.c
Log:
Fixed bug 3027 (Places menu showing %20) by copying glib code
Modified: xfce4-places-plugin/trunk/ChangeLog
===================================================================
--- xfce4-places-plugin/trunk/ChangeLog 2007-03-25 05:18:00 UTC (rev 2565)
+++ xfce4-places-plugin/trunk/ChangeLog 2007-03-25 06:31:29 UTC (rev 2566)
@@ -1,3 +1,7 @@
+2007-03-25 Diego Ongaro ongardie at gmail.com
+
+ * Fixed bug 3027 (Places menu showing %20) by copying glib code
+
2007-03-14 Diego Ongaro ongardie at gmail.com
- * initial beta release, packaged outside svn
+ * initial beta release, packaged outside svn
Modified: xfce4-places-plugin/trunk/panel-plugin/Makefile.am
===================================================================
--- xfce4-places-plugin/trunk/panel-plugin/Makefile.am 2007-03-25 05:18:00 UTC (rev 2565)
+++ xfce4-places-plugin/trunk/panel-plugin/Makefile.am 2007-03-25 06:31:29 UTC (rev 2566)
@@ -1,6 +1,6 @@
INCLUDES = \
-I$(top_srcdir) \
- -DG_LOG_DOMAIN=\"xfce4-places-plugin\" \
+ -DG_LOG_DOMAIN=\"xfce4-places-plugin\" \
-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
$(PLATFORM_CPPFLAGS)
@@ -10,11 +10,12 @@
plugin_PROGRAMS = \
xfce4-places-plugin
-xfce4_places_plugin_SOURCES = \
+xfce4_places_plugin_SOURCES = \
+ unescape_uri.c \
places.h \
places.c
-xfce4_places_plugin_CFLAGS = \
+xfce4_places_plugin_CFLAGS = \
$(GTK_CFLAGS) \
$(LIBXFCE4UTIL_CFLAGS) \
$(LIBXFCEGUI4_CFLAGS) \
Modified: xfce4-places-plugin/trunk/panel-plugin/places.c
===================================================================
--- xfce4-places-plugin/trunk/panel-plugin/places.c 2007-03-25 05:18:00 UTC (rev 2565)
+++ xfce4-places-plugin/trunk/panel-plugin/places.c 2007-03-25 06:31:29 UTC (rev 2566)
@@ -32,6 +32,7 @@
#include <libxfcegui4/libxfcegui4.h>
#include "places.h"
+#include "unescape_uri.c"
#define PLUGIN_NAME "places"
@@ -149,7 +150,7 @@
g_ptr_array_add(pd->bookmarks_user, places_construct_BookmarkInfo(g_strdup(split[1]),
g_strdup(split[0]), "gnome-fs-directory"));
}else{
- g_ptr_array_add(pd->bookmarks_user, places_construct_BookmarkInfo(g_strdup(g_strrstr(lines[i], "/") + sizeof(gchar)),
+ g_ptr_array_add(pd->bookmarks_user, places_construct_BookmarkInfo(places_unescape_uri_string(g_strrstr(lines[i], "/") + sizeof(gchar)),
g_strdup(lines[i]), "gnome-fs-directory"));
}
g_free(split);
Added: xfce4-places-plugin/trunk/panel-plugin/unescape_uri.c
===================================================================
--- xfce4-places-plugin/trunk/panel-plugin/unescape_uri.c (rev 0)
+++ xfce4-places-plugin/trunk/panel-plugin/unescape_uri.c 2007-03-25 06:31:29 UTC (rev 2566)
@@ -0,0 +1,118 @@
+/* xfce4-places-plugin
+ *
+ * Extracted from glib/gconvert.c
+ * GLIB - Library of useful routines for C programming
+ *
+ * gconvert.c: Convert between character sets using iconv
+ * Copyright Red Hat Inc., 2000
+ * Authors: Havoc Pennington <hp at redhat.com>, Owen Taylor <otaylor at redhat.com>
+ *
+ * Though gconvert.c is licensed under the LGPL, these extracts are distributed under the GPL,
+ * applying section 3 of the LGPL license:
+ * "3. You may opt to apply the terms of the ordinary GNU General Public
+ * License instead of this License to a given copy of the Library..."
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <string.h>
+#include <glib.h>
+
+static int
+unescape_character (const char *scanner)
+{
+ int first_digit;
+ int second_digit;
+
+ first_digit = g_ascii_xdigit_value (scanner[0]);
+ if (first_digit < 0)
+ return -1;
+
+ second_digit = g_ascii_xdigit_value (scanner[1]);
+ if (second_digit < 0)
+ return -1;
+
+ return (first_digit << 4) | second_digit;
+}
+
+static gchar *
+g_unescape_uri_string (const char *escaped,
+ int len,
+ const char *illegal_escaped_characters,
+ gboolean ascii_must_not_be_escaped)
+{
+ const gchar *in, *in_end;
+ gchar *out, *result;
+ int c;
+
+ if (escaped == NULL)
+ return NULL;
+
+ if (len < 0)
+ len = strlen (escaped);
+
+ result = g_malloc (len + 1);
+
+ out = result;
+ for (in = escaped, in_end = escaped + len; in < in_end; in++)
+ {
+ c = *in;
+
+ if (c == '%')
+ {
+ /* catch partial escape sequences past the end of the substring */
+ if (in + 3 > in_end)
+ break;
+
+ c = unescape_character (in + 1);
+
+ /* catch bad escape sequences and NUL characters */
+ if (c <= 0)
+ break;
+
+ /* catch escaped ASCII */
+ if (ascii_must_not_be_escaped && c <= 0x7F)
+ break;
+
+ /* catch other illegal escaped characters */
+ if (strchr (illegal_escaped_characters, c) != NULL)
+ break;
+
+ in += 2;
+ }
+
+ *out++ = c;
+ }
+
+ g_assert (out - result <= len);
+ *out = '\0';
+
+ if (in != in_end)
+ {
+ g_free (result);
+ return NULL;
+ }
+
+ return result;
+}
+
+/**
+ * Wrapper for use with xfce4-places-plugin
+ * author: Diego Ongaro
+ */
+static gchar *
+places_unescape_uri_string(const gchar* escaped) {
+ return g_unescape_uri_string(escaped, -1, "", FALSE);
+}
More information about the Goodies-commits
mailing list