playlist_song: fix absolute path support in playlists

Right now, a playlist with absolute pathnames can only add songs that
are in the same the directory of the playlist or under it.

If uri is an absolute pathname and base_uri is set,
playlist_check_translate_song() will check that base_uri is a prefix
of uri, excluding every other song in the music directory outside
base_uri.

I think in this case base_uri should be completely ignored (and made
NULL) and uri should just be checked against music root directory.
This commit is contained in:
Jesús Bravo Álvarez
2011-10-06 22:21:24 +02:00
committed by Max Kellermann
parent b2f03e76ff
commit 039b354490
2 changed files with 3 additions and 3 deletions

View File

@@ -114,9 +114,7 @@ playlist_check_translate_song(struct song *song, const char *base_uri)
if (g_path_is_absolute(uri)) {
/* XXX fs_charset vs utf8? */
char *prefix = base_uri != NULL
? map_uri_fs(base_uri)
: map_directory_fs(db_get_root());
char *prefix = map_directory_fs(db_get_root());
if (prefix == NULL || !g_str_has_prefix(uri, prefix) ||
uri[strlen(prefix)] != '/') {
@@ -127,6 +125,7 @@ playlist_check_translate_song(struct song *song, const char *base_uri)
return NULL;
}
base_uri = NULL;
uri += strlen(prefix) + 1;
g_free(prefix);
}