diff options
author | Max Kellermann <max@duempel.org> | 2010-01-06 07:58:48 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2010-01-06 08:00:35 +0100 |
commit | 01c5cb985cf79182e790d999307604e5fea1533a (patch) | |
tree | 96328c2b2f60ec814870263495c853ff692e3723 /src | |
parent | 8a5d2c3c836f89b4e96c70b57097cc86396e44d2 (diff) | |
download | mpd-01c5cb985cf79182e790d999307604e5fea1533a.tar.gz mpd-01c5cb985cf79182e790d999307604e5fea1533a.tar.xz mpd-01c5cb985cf79182e790d999307604e5fea1533a.zip |
playlist_queue: convert absolute paths
Accept absolute paths if they point into the music directory.
Diffstat (limited to '')
-rw-r--r-- | src/playlist_queue.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/playlist_queue.c b/src/playlist_queue.c index 269b34553..9940c3323 100644 --- a/src/playlist_queue.c +++ b/src/playlist_queue.c @@ -102,10 +102,22 @@ check_translate_song(struct song *song, const char *base_uri) } if (g_path_is_absolute(uri)) { - /* local files must be relative to the music - directory */ - song_free(song); - return NULL; + /* XXX fs_charset vs utf8? */ + char *prefix = base_uri != NULL + ? map_uri_fs(base_uri) + : map_directory_fs(db_get_root()); + + if (prefix == NULL || !g_str_has_prefix(uri, prefix) || + uri[strlen(prefix)] != '/') { + /* local files must be relative to the music + directory */ + g_free(prefix); + song_free(song); + return NULL; + } + + uri += strlen(prefix) + 1; + g_free(prefix); } if (base_uri != NULL) |