aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-04 16:22:08 +0100
committerMax Kellermann <max@duempel.org>2009-01-04 16:22:08 +0100
commit7d87f71d830c62714c67af4728455b57241c90e7 (patch)
tree3be4fa390d816c665c47d27be35214c57047a388
parentef0b328a3c917095df0d3b61625d4989aaa1a740 (diff)
downloadmpd-7d87f71d830c62714c67af4728455b57241c90e7.tar.gz
mpd-7d87f71d830c62714c67af4728455b57241c90e7.tar.xz
mpd-7d87f71d830c62714c67af4728455b57241c90e7.zip
command: check URI scheme in "addid"
Check if the URI scheme is supported by MPD, and print an error message if not. Optimize the checks in "add" and "playlistadd".
Diffstat (limited to '')
-rw-r--r--src/command.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/command.c b/src/command.c
index 5e29cfa27..1d0f14dab 100644
--- a/src/command.c
+++ b/src/command.c
@@ -461,13 +461,14 @@ handle_add(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
return print_playlist_result(client, result);
}
- if (isRemoteUrl(uri))
- return addToPlaylist(uri, NULL);
-
if (uri_has_scheme(uri)) {
- command_error(client, ACK_ERROR_NO_EXIST,
- "unsupported URI scheme");
- return COMMAND_RETURN_ERROR;
+ if (!isRemoteUrl(uri)) {
+ command_error(client, ACK_ERROR_NO_EXIST,
+ "unsupported URI scheme");
+ return COMMAND_RETURN_ERROR;
+ }
+
+ return addToPlaylist(uri, NULL);
}
result = addAllIn(uri);
@@ -495,8 +496,15 @@ handle_addid(struct client *client, int argc, char *argv[])
client_get_uid(client),
&added_id);
#endif
- } else
+ } else {
+ if (uri_has_scheme(uri) && !isRemoteUrl(uri)) {
+ command_error(client, ACK_ERROR_NO_EXIST,
+ "unsupported URI scheme");
+ return COMMAND_RETURN_ERROR;
+ }
+
result = addToPlaylist(uri, &added_id);
+ }
if (result != PLAYLIST_RESULT_SUCCESS)
return print_playlist_result(client, result);
@@ -1249,12 +1257,14 @@ handle_playlistadd(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
char *uri = argv[2];
enum playlist_result result;
- if (isRemoteUrl(uri))
+ if (uri_has_scheme(uri)) {
+ if (!isRemoteUrl(uri)) {
+ command_error(client, ACK_ERROR_NO_EXIST,
+ "unsupported URI scheme");
+ return COMMAND_RETURN_ERROR;
+ }
+
result = spl_append_uri(uri, playlist);
- else if (uri_has_scheme(uri)) {
- command_error(client, ACK_ERROR_NO_EXIST,
- "unsupported URI scheme");
- return COMMAND_RETURN_ERROR;
} else
result = addAllInToStoredPlaylist(uri, playlist);