db/update/Walk: use GetFilenameSuffix() instead of uri_get_suffix()

Unlike GetFilenameSuffix(), uri_get_suffix() removes the query string
first, which breaks file names with question marks in the name.
Therefore, uri_get_suffix() shall only be applied to remote URIs.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1316
This commit is contained in:
Max Kellermann 2021-10-28 15:04:30 +02:00
parent bfb1b641f9
commit 03f99dd26e
4 changed files with 11 additions and 6 deletions

1
NEWS
View File

@ -3,6 +3,7 @@ ver 0.23.3 (not yet released)
- add optional position parameter to "add" and "playlistadd"
- allow range in "playlistdelete"
* database
- fix scanning files with question mark in the name
- inotify: fix use-after-free bug
* output
- alsa: add option "stop_dsd_silence" to work around DSD DAC noise

View File

@ -224,10 +224,12 @@ GetChromaprintCommand::DecodeFile(std::string_view suffix, InputStream &is,
inline void
GetChromaprintCommand::DecodeFile()
{
const auto suffix = uri_get_suffix(uri);
if (suffix.empty())
const char *_suffix = PathTraitsUTF8::GetFilenameSuffix(uri.c_str());
if (_suffix == nullptr)
return;
const std::string_view suffix{_suffix};
InputStreamPtr input_stream;
try {

View File

@ -188,8 +188,8 @@ UpdateWalk::UpdateRegularFile(Directory &directory,
const char *name,
const StorageFileInfo &info) noexcept
{
const auto suffix = uri_get_suffix(name);
if (suffix.empty())
const char *suffix = PathTraitsUTF8::GetFilenameSuffix(name);
if (suffix == nullptr)
return false;
return UpdateSongFile(directory, name, suffix, info) ||

View File

@ -395,10 +395,12 @@ TryContainerDecoder(DecoderBridge &bridge, Path path_fs,
static bool
decoder_run_file(DecoderBridge &bridge, const char *uri_utf8, Path path_fs)
{
const auto suffix = uri_get_suffix(uri_utf8);
if (suffix.empty())
const char *_suffix = PathTraitsUTF8::GetFilenameSuffix(uri_utf8);
if (_suffix == nullptr)
return false;
const std::string_view suffix{_suffix};
InputStreamPtr input_stream;
try {