aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-07 13:37:04 +0200
committerMax Kellermann <max@duempel.org>2008-09-07 13:37:04 +0200
commitdc353eca802d8889dd868188d977fb0957cc8554 (patch)
tree16c63765590929f028a166c58413dca7da8d8890 /src/playlist.c
parent59efed3e8e3da3be85fada02a533cb79fba21569 (diff)
downloadmpd-dc353eca802d8889dd868188d977fb0957cc8554.tar.gz
mpd-dc353eca802d8889dd868188d977fb0957cc8554.tar.xz
mpd-dc353eca802d8889dd868188d977fb0957cc8554.zip
playlist: added is_valid_playlist_name()
The function valid_playlist_name() checks the name, but it insists on reporting an eventual error to the client. The new function is_valid_playlist_name() is more generic: it just returns a boolean, and does not care what the caller will use it for. The old function valid_playlist_name() will be removed later.
Diffstat (limited to 'src/playlist.c')
-rw-r--r--src/playlist.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/playlist.c b/src/playlist.c
index 743a67d87..3c41b4d79 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -1509,11 +1509,16 @@ void findSongsInPlaylist(int fd, int numItems, LocateTagItem * items)
* protocol (and compatibility with all clients) to support idiots who
* put '\r' and '\n' in filenames isn't going to happen, either.
*/
+int is_valid_playlist_name(const char *utf8path)
+{
+ return strchr(utf8path, '/') == NULL &&
+ strchr(utf8path, '\n') == NULL &&
+ strchr(utf8path, '\r') == NULL;
+}
+
int valid_playlist_name(int err_fd, const char *utf8path)
{
- if (strchr(utf8path, '/') ||
- strchr(utf8path, '\n') ||
- strchr(utf8path, '\r')) {
+ if (!is_valid_playlist_name(utf8path)) {
commandError(err_fd, ACK_ERROR_ARG, "playlist name \"%s\" is "
"invalid: playlist names may not contain slashes,"
" newlines or carriage returns",