From 03f99dd26eef129d5373dfa4ccb1a6324503d6a2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 28 Oct 2021 15:04:30 +0200 Subject: [PATCH] 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 --- NEWS | 1 + src/command/FingerprintCommands.cxx | 6 ++++-- src/db/update/Walk.cxx | 4 ++-- src/decoder/Thread.cxx | 6 ++++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 7f2fecb9b..0b0e9e311 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/src/command/FingerprintCommands.cxx b/src/command/FingerprintCommands.cxx index d4b0e7230..490c25f9c 100644 --- a/src/command/FingerprintCommands.cxx +++ b/src/command/FingerprintCommands.cxx @@ -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 { diff --git a/src/db/update/Walk.cxx b/src/db/update/Walk.cxx index c4cde3203..be71e7195 100644 --- a/src/db/update/Walk.cxx +++ b/src/db/update/Walk.cxx @@ -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) || diff --git a/src/decoder/Thread.cxx b/src/decoder/Thread.cxx index 6e4793747..273b77df7 100644 --- a/src/decoder/Thread.cxx +++ b/src/decoder/Thread.cxx @@ -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 {