diff options
author | Max Kellermann <max@duempel.org> | 2015-02-09 07:55:06 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-02-09 07:55:06 +0100 |
commit | 676dfabc91b5f9b0ff54ce145a34352fe0a43202 (patch) | |
tree | f9f5f28f632492583aa211ab9cc4ff9aee9a0e8f /src/command/QueueCommands.cxx | |
parent | 60e6d1d61b1c56d3a94fa73779f240b8d7d43a89 (diff) | |
download | mpd-676dfabc91b5f9b0ff54ce145a34352fe0a43202.tar.gz mpd-676dfabc91b5f9b0ff54ce145a34352fe0a43202.tar.xz mpd-676dfabc91b5f9b0ff54ce145a34352fe0a43202.zip |
command/{Queue,File}Commands: drop "file:///" prefix for absolute paths
Requiring this prefix makes the client's intention very clear, but it
was too hard to understand why this prefix was needed. Initially, my
intention was to differentiate from broken clients which prefix relate
URIs with a slash; once MPD allowed that. In the past few years
however, MPD has disallowed that, and there was no significant
breakage (except for the "add /" special case which some clients
apparently still do). So I figure it's about time to define that an
URI that begins with a slash points to an arbitrary file on the file
system.
Diffstat (limited to '')
-rw-r--r-- | src/command/QueueCommands.cxx | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/command/QueueCommands.cxx b/src/command/QueueCommands.cxx index 20634652a..d461170fd 100644 --- a/src/command/QueueCommands.cxx +++ b/src/command/QueueCommands.cxx @@ -43,18 +43,13 @@ #include <string.h> static const char * -translate_uri(Client &client, const char *uri) +translate_uri(const char *uri) { if (memcmp(uri, "file:///", 8) == 0) /* drop the "file://", leave only an absolute path (starting with a slash) */ return uri + 7; - if (PathTraitsUTF8::IsAbsolute(uri)) { - command_error(client, ACK_ERROR_NO_EXIST, "Malformed URI"); - return nullptr; - } - return uri; } @@ -70,9 +65,7 @@ handle_add(Client &client, ConstBuffer<const char *> args) here */ uri = ""; - uri = translate_uri(client, uri); - if (uri == nullptr) - return CommandResult::ERROR; + uri = translate_uri(uri); if (uri_has_scheme(uri) || PathTraitsUTF8::IsAbsolute(uri)) { const SongLoader loader(client); @@ -101,9 +94,7 @@ handle_add(Client &client, ConstBuffer<const char *> args) CommandResult handle_addid(Client &client, ConstBuffer<const char *> args) { - const char *const uri = translate_uri(client, args.front()); - if (uri == nullptr) - return CommandResult::ERROR; + const char *const uri = translate_uri(args.front()); const SongLoader loader(client); Error error; |