summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Pauls <daniel1708.de+git@gmail.com>2019-05-29 19:40:45 +0200
committerErnestas Kulik <ekulik@redhat.com>2019-06-02 11:25:42 +0200
commite76cfc99855dafc2bfc46e0544f5818653ce46c6 (patch)
tree439daccfadae547ef87d7364dde4d9227521b17b
parenta4e46a9701be5ed1f1d5cd02133ee5a42cbdf0c8 (diff)
downloadnautilus-e76cfc99855dafc2bfc46e0544f5818653ce46c6.tar.gz
location-entry: Allow white space padding
If a path in the location entry has white space as a padding Nautilus will throw an error. Stripping it before parsing will fix this. Fixes https://gitlab.gnome.org/GNOME/nautilus/issues/1030
-rw-r--r--src/nautilus-location-entry.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/nautilus-location-entry.c b/src/nautilus-location-entry.c
index 0203e278e..05bc6fb15 100644
--- a/src/nautilus-location-entry.c
+++ b/src/nautilus-location-entry.c
@@ -370,6 +370,8 @@ try_to_expand_path (gpointer callback_data)
editable = GTK_EDITABLE (entry);
user_location = gtk_editable_get_chars (editable, 0, -1);
user_location_length = g_utf8_strlen (user_location, -1);
+ user_location = g_strchug (user_location);
+ user_location = g_strchomp (user_location);
priv->idle_id = 0;
uri_scheme = g_uri_parse_scheme (user_location);
@@ -714,19 +716,23 @@ nautilus_location_entry_activate (GtkEntry *entry)
NautilusLocationEntryPrivate *priv;
const gchar *entry_text;
gchar *full_path, *uri_scheme = NULL;
+ g_autofree char *path = NULL;
loc_entry = NAUTILUS_LOCATION_ENTRY (entry);
priv = nautilus_location_entry_get_instance_private (loc_entry);
entry_text = gtk_entry_get_text (entry);
+ path = g_strdup (entry_text);
+ path = g_strchug (path);
+ path = g_strchomp (path);
- if (entry_text != NULL && *entry_text != '\0')
+ if (path != NULL && *path != '\0')
{
- uri_scheme = g_uri_parse_scheme (entry_text);
+ uri_scheme = g_uri_parse_scheme (path);
- if (!g_path_is_absolute (entry_text) && uri_scheme == NULL && entry_text[0] != '~')
+ if (!g_path_is_absolute (path) && uri_scheme == NULL && path[0] != '~')
{
/* Fix non absolute paths */
- full_path = g_build_filename (priv->current_directory, entry_text, NULL);
+ full_path = g_build_filename (priv->current_directory, path, NULL);
gtk_entry_set_text (entry, full_path);
g_free (full_path);
}
@@ -832,10 +838,16 @@ editable_activate_callback (GtkEntry *entry,
{
NautilusLocationEntry *self = user_data;
const char *entry_text;
+ g_autofree gchar *path = NULL;
entry_text = gtk_entry_get_text (entry);
- if (entry_text != NULL && *entry_text != '\0')
+ path = g_strdup (entry_text);
+ path = g_strchug (path);
+ path = g_strchomp (path);
+
+ if (path != NULL && *path != '\0')
{
+ gtk_entry_set_text (entry, path);
emit_location_changed (self);
}
}