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
cbaa98c1
Commit
cbaa98c1
authored
Nov 04, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input/curl: apply the "charset" parameter to Icy-Name
Extends the URI fragment parameter added in commit
cf9ee339
Closes
https://github.com/MusicPlayerDaemon/MPD/issues/679
parent
ed327c59
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
1 deletion
+53
-1
CurlInputPlugin.cxx
src/input/plugins/CurlInputPlugin.cxx
+53
-1
No files found.
src/input/plugins/CurlInputPlugin.cxx
View file @
cbaa98c1
...
...
@@ -40,6 +40,14 @@
#include "util/Domain.hxx"
#include "Log.hxx"
#include "PluginUnavailable.hxx"
#include "config.h"
#ifdef HAVE_ICU_CONVERTER
#include "lib/icu/Converter.hxx"
#include "util/AllocatedString.hxx"
#include "util/UriExtract.hxx"
#include "util/UriQueryParser.hxx"
#endif
#include <cinttypes>
...
...
@@ -176,6 +184,45 @@ CurlInputStream::FreeEasyIndirect() noexcept
});
}
#ifdef HAVE_ICU_CONVERTER
static
std
::
unique_ptr
<
IcuConverter
>
CreateIcuConverterForUri
(
const
char
*
uri
)
{
const
char
*
fragment
=
uri_get_fragment
(
uri
);
if
(
fragment
==
nullptr
)
return
nullptr
;
const
auto
charset
=
UriFindRawQueryParameter
(
fragment
,
"charset"
);
if
(
charset
==
nullptr
)
return
nullptr
;
const
std
::
string
copy
(
charset
.
data
,
charset
.
size
);
return
IcuConverter
::
Create
(
copy
.
c_str
());
}
#endif
template
<
typename
F
>
static
void
WithConvertedTagValue
(
const
char
*
uri
,
const
char
*
value
,
F
&&
f
)
noexcept
{
#ifdef HAVE_ICU_CONVERTER
try
{
auto
converter
=
CreateIcuConverterForUri
(
uri
);
if
(
converter
)
{
f
(
converter
->
ToUTF8
(
value
).
c_str
());
return
;
}
}
catch
(...)
{
}
#else
(
void
)
uri
;
#endif
f
(
value
);
}
void
CurlInputStream
::
OnHeaders
(
unsigned
status
,
std
::
multimap
<
std
::
string
,
std
::
string
>
&&
headers
)
...
...
@@ -217,7 +264,12 @@ CurlInputStream::OnHeaders(unsigned status,
if
(
i
!=
headers
.
end
())
{
TagBuilder
tag_builder
;
tag_builder
.
AddItem
(
TAG_NAME
,
i
->
second
.
c_str
());
WithConvertedTagValue
(
GetURI
(),
i
->
second
.
c_str
(),
[
&
tag_builder
](
const
char
*
value
){
tag_builder
.
AddItem
(
TAG_NAME
,
value
);
});
SetTag
(
tag_builder
.
CommitNew
());
}
...
...
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