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
5274fee8
Commit
5274fee8
authored
Dec 22, 2010
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist_song: add flag "secure"
Optionally allow all local files. "Insecure" mode is used for printing playlists.
parent
5462f34e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
14 deletions
+24
-14
command.c
src/command.c
+1
-1
playlist_print.c
src/playlist_print.c
+1
-1
playlist_queue.c
src/playlist_queue.c
+4
-4
playlist_queue.h
src/playlist_queue.h
+4
-2
playlist_song.c
src/playlist_song.c
+7
-5
playlist_song.h
src/playlist_song.h
+7
-1
No files found.
src/command.c
View file @
5274fee8
...
...
@@ -747,7 +747,7 @@ handle_load(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
{
enum
playlist_result
result
;
result
=
playlist_open_into_queue
(
argv
[
1
],
&
g_playlist
);
result
=
playlist_open_into_queue
(
argv
[
1
],
&
g_playlist
,
true
);
if
(
result
!=
PLAYLIST_RESULT_NO_SUCH_LIST
)
return
result
;
...
...
src/playlist_print.c
View file @
5274fee8
...
...
@@ -153,7 +153,7 @@ playlist_provider_print(struct client *client, const char *uri,
char
*
base_uri
=
uri
!=
NULL
?
g_path_get_dirname
(
uri
)
:
NULL
;
while
((
song
=
playlist_plugin_read
(
playlist
))
!=
NULL
)
{
song
=
playlist_check_translate_song
(
song
,
base_uri
);
song
=
playlist_check_translate_song
(
song
,
base_uri
,
false
);
if
(
song
==
NULL
)
continue
;
...
...
src/playlist_queue.c
View file @
5274fee8
...
...
@@ -27,14 +27,14 @@
enum
playlist_result
playlist_load_into_queue
(
const
char
*
uri
,
struct
playlist_provider
*
source
,
struct
playlist
*
dest
)
struct
playlist
*
dest
,
bool
secure
)
{
enum
playlist_result
result
;
struct
song
*
song
;
char
*
base_uri
=
uri
!=
NULL
?
g_path_get_dirname
(
uri
)
:
NULL
;
while
((
song
=
playlist_plugin_read
(
source
))
!=
NULL
)
{
song
=
playlist_check_translate_song
(
song
,
base_uri
);
song
=
playlist_check_translate_song
(
song
,
base_uri
,
secure
);
if
(
song
==
NULL
)
continue
;
...
...
@@ -53,7 +53,7 @@ playlist_load_into_queue(const char *uri, struct playlist_provider *source,
}
enum
playlist_result
playlist_open_into_queue
(
const
char
*
uri
,
struct
playlist
*
dest
)
playlist_open_into_queue
(
const
char
*
uri
,
struct
playlist
*
dest
,
bool
secure
)
{
struct
input_stream
*
is
;
struct
playlist_provider
*
playlist
=
playlist_open_any
(
uri
,
&
is
);
...
...
@@ -61,7 +61,7 @@ playlist_open_into_queue(const char *uri, struct playlist *dest)
return
PLAYLIST_RESULT_NO_SUCH_LIST
;
enum
playlist_result
result
=
playlist_load_into_queue
(
uri
,
playlist
,
dest
);
playlist_load_into_queue
(
uri
,
playlist
,
dest
,
secure
);
playlist_plugin_close
(
playlist
);
if
(
is
!=
NULL
)
...
...
src/playlist_queue.h
View file @
5274fee8
...
...
@@ -26,6 +26,8 @@
#include "playlist.h"
#include <stdbool.h>
struct
playlist_provider
;
struct
playlist
;
...
...
@@ -38,14 +40,14 @@ struct playlist;
*/
enum
playlist_result
playlist_load_into_queue
(
const
char
*
uri
,
struct
playlist_provider
*
source
,
struct
playlist
*
dest
);
struct
playlist
*
dest
,
bool
secure
);
/**
* Opens a playlist with a playlist plugin and append to the specified
* play queue.
*/
enum
playlist_result
playlist_open_into_queue
(
const
char
*
uri
,
struct
playlist
*
dest
);
playlist_open_into_queue
(
const
char
*
uri
,
struct
playlist
*
dest
,
bool
secure
);
#endif
src/playlist_song.c
View file @
5274fee8
...
...
@@ -84,7 +84,8 @@ apply_song_metadata(struct song *dest, const struct song *src)
}
struct
song
*
playlist_check_translate_song
(
struct
song
*
song
,
const
char
*
base_uri
)
playlist_check_translate_song
(
struct
song
*
song
,
const
char
*
base_uri
,
bool
secure
)
{
struct
song
*
dest
;
...
...
@@ -111,16 +112,17 @@ playlist_check_translate_song(struct song *song, const char *base_uri)
?
map_uri_fs
(
base_uri
)
:
map_directory_fs
(
db_get_root
());
if
(
prefix
==
NULL
||
!
g_str_has_prefix
(
uri
,
prefix
)
||
uri
[
strlen
(
prefix
)]
!=
'/'
)
{
if
(
prefix
!=
NULL
&&
g_str_has_prefix
(
uri
,
prefix
)
&&
uri
[
strlen
(
prefix
)]
==
'/'
)
uri
+=
strlen
(
prefix
)
+
1
;
else
if
(
!
secure
)
{
/* local files must be relative to the music
directory */
directory
when "secure" is enabled
*/
g_free
(
prefix
);
song_free
(
song
);
return
NULL
;
}
uri
+=
strlen
(
prefix
)
+
1
;
g_free
(
prefix
);
}
...
...
src/playlist_song.h
View file @
5274fee8
...
...
@@ -20,12 +20,18 @@
#ifndef MPD_PLAYLIST_SONG_H
#define MPD_PLAYLIST_SONG_H
#include <stdbool.h>
/**
* Verifies the song, returns NULL if it is unsafe. Translate the
* song to a new song object within the database, if it is a local
* file. The old song object is freed.
*
* @param secure if true, then local files are only allowed if they
* are relative to base_uri
*/
struct
song
*
playlist_check_translate_song
(
struct
song
*
song
,
const
char
*
base_uri
);
playlist_check_translate_song
(
struct
song
*
song
,
const
char
*
base_uri
,
bool
secure
);
#endif
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