Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
bdfb6c23
Commit
bdfb6c23
authored
Jan 25, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist: moved is_valid_playlist_name() to stored_playlist.c
parent
98cb8f39
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
22 deletions
+32
-22
playlist.c
src/playlist.c
+0
-16
playlist_save.c
src/playlist_save.c
+1
-1
stored_playlist.c
src/stored_playlist.c
+23
-5
stored_playlist.h
src/stored_playlist.h
+8
-0
No files found.
src/playlist.c
View file @
bdfb6c23
...
...
@@ -1091,19 +1091,3 @@ unsigned getPlaylistSongId(unsigned song)
{
return
queue_position_to_id
(
&
playlist
.
queue
,
song
);
}
/*
* Not supporting '/' was done out of laziness, and we should really
* strive to support it in the future.
*
* Not supporting '\r' and '\n' is done out of protocol limitations (and
* arguably laziness), but bending over head over heels to modify the
* 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
;
}
src/playlist_save.c
View file @
bdfb6c23
...
...
@@ -70,7 +70,7 @@ spl_save_queue(const char *name_utf8, const struct queue *queue)
char
*
path_fs
;
FILE
*
file
;
if
(
!
is_valid_playlist
_name
(
name_utf8
))
if
(
!
spl_valid
_name
(
name_utf8
))
return
PLAYLIST_RESULT_BAD_NAME
;
path_fs
=
map_spl_utf8_to_fs
(
name_utf8
);
...
...
src/stored_playlist.c
View file @
bdfb6c23
...
...
@@ -48,6 +48,25 @@ spl_global_init(void)
DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS
);
}
bool
spl_valid_name
(
const
char
*
name_utf8
)
{
/*
* Not supporting '/' was done out of laziness, and we should
* really strive to support it in the future.
*
* Not supporting '\r' and '\n' is done out of protocol
* limitations (and arguably laziness), but bending over head
* over heels to modify the protocol (and compatibility with
* all clients) to support idiots who put '\r' and '\n' in
* filenames isn't going to happen, either.
*/
return
strchr
(
name_utf8
,
'/'
)
==
NULL
&&
strchr
(
name_utf8
,
'\n'
)
==
NULL
&&
strchr
(
name_utf8
,
'\r'
)
==
NULL
;
}
static
struct
stored_playlist_info
*
load_playlist_info
(
const
char
*
parent_path_fs
,
const
char
*
name_fs
)
{
...
...
@@ -158,7 +177,7 @@ spl_load(const char *utf8path)
char
buffer
[
MPD_PATH_MAX
];
char
*
path_fs
;
if
(
!
is_valid_playlist
_name
(
utf8path
))
if
(
!
spl_valid
_name
(
utf8path
))
return
NULL
;
path_fs
=
map_spl_utf8_to_fs
(
utf8path
);
...
...
@@ -279,7 +298,7 @@ spl_clear(const char *utf8path)
char
*
path_fs
;
FILE
*
file
;
if
(
!
is_valid_playlist
_name
(
utf8path
))
if
(
!
spl_valid
_name
(
utf8path
))
return
PLAYLIST_RESULT_BAD_NAME
;
path_fs
=
map_spl_utf8_to_fs
(
utf8path
);
...
...
@@ -350,7 +369,7 @@ spl_append_song(const char *utf8path, struct song *song)
struct
stat
st
;
char
*
path_fs
;
if
(
!
is_valid_playlist
_name
(
utf8path
))
if
(
!
spl_valid
_name
(
utf8path
))
return
PLAYLIST_RESULT_BAD_NAME
;
path_fs
=
map_spl_utf8_to_fs
(
utf8path
);
...
...
@@ -429,8 +448,7 @@ spl_rename(const char *utf8from, const char *utf8to)
char
*
from_path_fs
,
*
to_path_fs
;
static
enum
playlist_result
ret
;
if
(
!
is_valid_playlist_name
(
utf8from
)
||
!
is_valid_playlist_name
(
utf8to
))
if
(
!
spl_valid_name
(
utf8from
)
||
!
spl_valid_name
(
utf8to
))
return
PLAYLIST_RESULT_BAD_NAME
;
from_path_fs
=
map_spl_utf8_to_fs
(
utf8from
);
...
...
src/stored_playlist.h
View file @
bdfb6c23
...
...
@@ -22,6 +22,7 @@
#include "playlist.h"
#include <glib.h>
#include <stdbool.h>
#include <time.h>
struct
song
;
...
...
@@ -41,6 +42,13 @@ void
spl_global_init
(
void
);
/**
* Determines whether the specified string is a valid name for a
* stored playlist.
*/
bool
spl_valid_name
(
const
char
*
name_utf8
);
/**
* Returns a list of stored_playlist_info struct pointers. Returns
* NULL if an error occured.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment