diff options
author | Thomas Guillem <thomas@gllm.fr> | 2020-04-14 22:07:51 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2020-04-15 13:50:12 +0200 |
commit | b18074f8998f7aefc326e09932db37aae4f13062 (patch) | |
tree | 5fe011dfe37e876e4bc287495f09b9f78c53217e /src/storage | |
parent | 3d8067a041fae2c117772a498702b9f40fe24595 (diff) |
storage/curl: fix path comparison when the server escapes differently
Unescape the base path and the path coming from the server (href) to fix the
comparison when the server uses different escaped characters.
The outputted name need to be unescaped. Doing that before or after the
HrefToEscapedName() call should not change the current behavior.
Diffstat (limited to 'src/storage')
-rw-r--r-- | src/storage/plugins/CurlStorage.cxx | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/storage/plugins/CurlStorage.cxx b/src/storage/plugins/CurlStorage.cxx index 9452f7e54..e47aa7ae9 100644 --- a/src/storage/plugins/CurlStorage.cxx +++ b/src/storage/plugins/CurlStorage.cxx @@ -482,7 +482,7 @@ class HttpListDirectoryOperation final : public PropfindOperation { public: HttpListDirectoryOperation(CurlGlobal &curl, const char *uri) :PropfindOperation(curl, uri, 1), - base_path(UriPathOrSlash(uri)) {} + base_path(CurlUnescape(GetEasy(), UriPathOrSlash(uri))) {} std::unique_ptr<StorageDirectoryReader> Perform() { DeferStart(); @@ -507,8 +507,7 @@ private: /* kludge: ignoring case in this comparison to avoid false negatives if the web server uses a different - case in hex digits in escaped characters; TODO: - implement properly */ + case */ path = StringAfterPrefixIgnoreCase(path, base_path.c_str()); if (path == nullptr || *path == 0) return nullptr; @@ -531,11 +530,12 @@ protected: if (r.status != 200) return; - const auto escaped_name = HrefToEscapedName(r.href.c_str()); - if (escaped_name.IsNull()) + std::string href = CurlUnescape(GetEasy(), r.href.c_str()); + const auto name = HrefToEscapedName(href.c_str()); + if (name.IsNull()) return; - entries.emplace_front(CurlUnescape(GetEasy(), escaped_name)); + entries.emplace_front(std::string(name.data, name.size)); auto &info = entries.front().info; info = StorageFileInfo(r.collection |