Merge branch 'v0.21.x'

This commit is contained in:
Max Kellermann
2019-07-29 11:15:04 +02:00
7 changed files with 69 additions and 14 deletions
+19
View File
@@ -25,6 +25,9 @@
#include "util/UriUtil.hxx"
#include "song/DetachedSong.hxx"
#include <algorithm>
#include <string>
#include <string.h>
static void
@@ -66,6 +69,22 @@ playlist_check_translate_song(DetachedSong &song, const char *base_uri,
base_uri = nullptr;
const char *uri = song.GetURI();
#ifdef _WIN32
if (!PathTraitsUTF8::IsAbsolute(uri) && strchr(uri, '\\') != nullptr) {
/* Windows uses the backslash as path separator, but
the MPD protocol uses the (forward) slash by
definition; to allow backslashes in relative URIs
loaded from playlist files, this step converts all
backslashes to (forward) slashes */
std::string new_uri(uri);
std::replace(new_uri.begin(), new_uri.end(), '\\', '/');
song.SetURI(std::move(new_uri));
uri = song.GetURI();
}
#endif
if (base_uri != nullptr && !uri_has_scheme(uri) &&
!PathTraitsUTF8::IsAbsolute(uri))
song.SetURI(PathTraitsUTF8::Build(base_uri, uri));