Skip to content

Commit

Permalink
use rb_uri_is_descendant in a few places
Browse files Browse the repository at this point in the history
This is better than the string prefix checks we had before as it ensures
that the end of the ancestor URI is also the end of a path component of
the descendant.
  • Loading branch information
Jonathan Matthew committed Mar 26, 2021
1 parent bb6fba6 commit 8b7309c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions plugins/generic-player/rb-generic-player-source.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ default_uri_from_playlist_uri (RBGenericPlayerSource *source, const char *uri)
char *full_uri;

mount_uri = rb_generic_player_source_get_mount_path (source);
if (g_str_has_prefix (uri, mount_uri)) {
if (rb_uri_is_descendant (uri, mount_uri)) {
return g_strdup (uri);
}

Expand All @@ -704,7 +704,7 @@ default_uri_to_playlist_uri (RBGenericPlayerSource *source, const char *uri, Tot
case TOTEM_PL_PARSER_IRIVER_PLA:
/* we need absolute paths within the device filesystem for this format */
mount_uri = rb_generic_player_source_get_mount_path (source);
if (g_str_has_prefix (uri, mount_uri) == FALSE) {
if (rb_uri_is_descendant (uri, mount_uri) == FALSE) {
rb_debug ("uri %s is not under device mount uri %s", uri, mount_uri);
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion rhythmdb/rhythmdb-monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ rhythmdb_directory_change_cb (GFileMonitor *monitor,

/* ignore new files outside of the library locations */
for (i = 0; db->priv->library_locations[i] != NULL; i++) {
if (g_str_has_prefix (canon_uri, db->priv->library_locations[i])) {
if (rb_uri_is_descendant (canon_uri, db->priv->library_locations[i])) {
in_library = TRUE;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion widgets/rb-import-dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ current_folder_changed_cb (GtkFileChooser *chooser, RBImportDialog *dialog)
locations = g_settings_get_strv (settings, "locations");
gtk_widget_set_sensitive (dialog->priv->copy_check, TRUE);
for (i = 0; locations[i] != NULL; i++) {
if (g_str_has_prefix (uri, locations[i])) {
if ((g_strcmp0 (uri, locations[i]) == 0) || rb_uri_is_descendant (uri, locations[i])) {
gtk_widget_set_sensitive (dialog->priv->copy_check, FALSE);
break;
}
Expand Down

0 comments on commit 8b7309c

Please sign in to comment.