Commit b18074f8 authored by Thomas Guillem's avatar Thomas Guillem Committed by Max Kellermann

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.
parent 3d8067a0
ver 0.21.23 (not yet released) ver 0.21.23 (not yet released)
* storage * storage
- curl: fix corrupt "href" values in the presence of XML entities - curl: fix corrupt "href" values in the presence of XML entities
- curl: unescape "href" values
* output * output
- alsa: implement channel mapping for 5.0 and 7.0 - alsa: implement channel mapping for 5.0 and 7.0
* player * player
......
...@@ -482,7 +482,7 @@ class HttpListDirectoryOperation final : public PropfindOperation { ...@@ -482,7 +482,7 @@ class HttpListDirectoryOperation final : public PropfindOperation {
public: public:
HttpListDirectoryOperation(CurlGlobal &curl, const char *uri) HttpListDirectoryOperation(CurlGlobal &curl, const char *uri)
:PropfindOperation(curl, uri, 1), :PropfindOperation(curl, uri, 1),
base_path(UriPathOrSlash(uri)) {} base_path(CurlUnescape(GetEasy(), UriPathOrSlash(uri))) {}
std::unique_ptr<StorageDirectoryReader> Perform() { std::unique_ptr<StorageDirectoryReader> Perform() {
DeferStart(); DeferStart();
...@@ -507,8 +507,7 @@ private: ...@@ -507,8 +507,7 @@ private:
/* kludge: ignoring case in this comparison to avoid /* kludge: ignoring case in this comparison to avoid
false negatives if the web server uses a different false negatives if the web server uses a different
case in hex digits in escaped characters; TODO: case */
implement properly */
path = StringAfterPrefixIgnoreCase(path, base_path.c_str()); path = StringAfterPrefixIgnoreCase(path, base_path.c_str());
if (path == nullptr || *path == 0) if (path == nullptr || *path == 0)
return nullptr; return nullptr;
...@@ -531,11 +530,12 @@ protected: ...@@ -531,11 +530,12 @@ protected:
if (r.status != 200) if (r.status != 200)
return; return;
const auto escaped_name = HrefToEscapedName(r.href.c_str()); std::string href = CurlUnescape(GetEasy(), r.href.c_str());
if (escaped_name.IsNull()) const auto name = HrefToEscapedName(href.c_str());
if (name.IsNull())
return; return;
entries.emplace_front(CurlUnescape(GetEasy(), escaped_name)); entries.emplace_front(std::string(name.data, name.size));
auto &info = entries.front().info; auto &info = entries.front().info;
info = StorageFileInfo(r.collection info = StorageFileInfo(r.collection
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment