Commit dc353eca authored by Max Kellermann's avatar Max Kellermann

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.
parent 59efed3e
......@@ -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",
......
......@@ -137,6 +137,8 @@ void searchForSongsInPlaylist(int fd, int numItems, LocateTagItem * items);
void findSongsInPlaylist(int fd, int numItems, LocateTagItem * items);
int is_valid_playlist_name(const char *utf8path);
int valid_playlist_name(int err_fd, const char *utf8path);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment