aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist_song.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/playlist_song.c')
-rw-r--r--src/playlist_song.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/playlist_song.c b/src/playlist_song.c
index 827098655..8a3ba303e 100644
--- a/src/playlist_song.c
+++ b/src/playlist_song.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2010 The Music Player Daemon Project
+ * Copyright (C) 2003-2011 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -84,7 +84,8 @@ apply_song_metadata(struct song *dest, const struct song *src)
}
struct song *
-playlist_check_translate_song(struct song *song, const char *base_uri)
+playlist_check_translate_song(struct song *song, const char *base_uri,
+ bool secure)
{
struct song *dest;
@@ -114,20 +115,19 @@ playlist_check_translate_song(struct song *song, const char *base_uri)
if (g_path_is_absolute(uri)) {
/* XXX fs_charset vs utf8? */
- char *prefix = map_directory_fs(db_get_root());
+ const char *prefix = mapper_get_music_directory();
- if (prefix == NULL || !g_str_has_prefix(uri, prefix) ||
- uri[strlen(prefix)] != '/') {
+ if (prefix != NULL && g_str_has_prefix(uri, prefix) &&
+ uri[strlen(prefix)] == '/')
+ uri += strlen(prefix) + 1;
+ else if (!secure) {
/* local files must be relative to the music
- directory */
- g_free(prefix);
+ directory when "secure" is enabled */
song_free(song);
return NULL;
}
base_uri = NULL;
- uri += strlen(prefix) + 1;
- g_free(prefix);
}
if (base_uri != NULL)
@@ -138,6 +138,12 @@ playlist_check_translate_song(struct song *song, const char *base_uri)
if (uri_has_scheme(uri)) {
dest = song_remote_new(uri);
g_free(uri);
+ } else if (g_path_is_absolute(uri) && secure) {
+ dest = song_file_load(uri, NULL);
+ if (dest == NULL) {
+ song_free(song);
+ return NULL;
+ }
} else {
dest = db_get_song(uri);
g_free(uri);