diff options
author | Daniel Pauls <daniel1708.de+git@gmail.com> | 2019-05-29 19:40:45 +0200 |
---|---|---|
committer | Ernestas Kulik <ekulik@redhat.com> | 2019-08-06 16:11:29 +0200 |
commit | de651e741b89e7e7163396d2c610ae95cca08410 (patch) | |
tree | e2b1cc5efc4e382e3bda402695782e806760643d | |
parent | 71a7967b920e4dba732e8063c166a819c98bce3f (diff) | |
download | nautilus-de651e741b89e7e7163396d2c610ae95cca08410.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.c | 22 |
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); } } |