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
90ea3bf9
Commit
90ea3bf9
authored
Jul 29, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist/Song: support backslash in relative URIs
Closes
https://github.com/MusicPlayerDaemon/MPD/issues/607
parent
83b08712
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
0 deletions
+38
-0
NEWS
NEWS
+2
-0
PlaylistSong.cxx
src/playlist/PlaylistSong.cxx
+16
-0
test_translate_song.cxx
test/test_translate_song.cxx
+20
-0
No files found.
NEWS
View file @
90ea3bf9
ver 0.21.12 (not yet released)
* Windows
- support backslash in relative URIs loaded from playlists
ver 0.21.11 (2019/07/03)
* input
...
...
src/playlist/PlaylistSong.cxx
View file @
90ea3bf9
...
...
@@ -66,6 +66,22 @@ playlist_check_translate_song(DetachedSong &song, const char *base_uri,
base_uri
=
nullptr
;
const
char
*
uri
=
song
.
GetURI
();
#ifdef _WIN32
if
(
!
PathTraitsUTF8
::
IsAbsolute
(
uri
)
&&
strchr
(
uri
,
'\\'
)
!=
nullptr
)
{
/* Windows uses the backslash as path separator, but
the MPD protocol uses the (forward) slash by
definition; to allow backslashes in relative URIs
loaded from playlist files, this step converts all
backslashes to (forward) slashes */
std
::
string
new_uri
(
uri
);
std
::
replace
(
new_uri
.
begin
(),
new_uri
.
end
(),
'\\'
,
'/'
);
song
.
SetURI
(
std
::
move
(
new_uri
));
uri
=
song
.
GetURI
();
}
#endif
if
(
base_uri
!=
nullptr
&&
!
uri_has_scheme
(
uri
)
&&
!
PathTraitsUTF8
::
IsAbsolute
(
uri
))
song
.
SetURI
(
PathTraitsUTF8
::
Build
(
base_uri
,
uri
));
...
...
test/test_translate_song.cxx
View file @
90ea3bf9
...
...
@@ -270,3 +270,23 @@ TEST_F(TranslateSongTest, Relative)
insecure_loader
));
EXPECT_EQ
(
se
,
ToString
(
song4
));
}
TEST_F
(
TranslateSongTest
,
Backslash
)
{
const
SongLoader
loader
(
reinterpret_cast
<
const
Database
*>
(
1
),
storage
);
DetachedSong
song1
(
"foo
\\
bar.ogg"
,
MakeTag2b
());
#ifdef _WIN32
/* on Windows, all backslashes are converted to slashes in
relative paths from playlists */
auto
se
=
ToString
(
DetachedSong
(
uri2
,
MakeTag2c
()));
EXPECT_TRUE
(
playlist_check_translate_song
(
song1
,
nullptr
,
loader
));
EXPECT_EQ
(
se
,
ToString
(
song1
));
#else
/* backslash only supported on Windows */
EXPECT_FALSE
(
playlist_check_translate_song
(
song1
,
nullptr
,
loader
));
#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