diff options
author | Max Kellermann <max@musicpd.org> | 2018-08-20 00:19:31 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-08-20 00:19:31 +0200 |
commit | 616abdda26389e105de0735afdeeb2e2d5c2b292 (patch) | |
tree | 883aa3918d434bba23209f50cd83d4868b780a0c /src/storage/plugins/CurlStorage.cxx | |
parent | cc64c715a200836f40b3d231e8b01a64ce8e9eda (diff) | |
parent | 14d3a7ae83cd8724308a82775ee8946befcfe435 (diff) |
Merge branch 'v0.20.x'
Diffstat (limited to 'src/storage/plugins/CurlStorage.cxx')
-rw-r--r-- | src/storage/plugins/CurlStorage.cxx | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/storage/plugins/CurlStorage.cxx b/src/storage/plugins/CurlStorage.cxx index b924c7cd8..37d00b6c7 100644 --- a/src/storage/plugins/CurlStorage.cxx +++ b/src/storage/plugins/CurlStorage.cxx @@ -36,6 +36,7 @@ #include "thread/Cond.hxx" #include "util/ASCII.hxx" #include "util/ChronoUtil.hxx" +#include "util/IterableSplitString.hxx" #include "util/RuntimeError.hxx" #include "util/StringCompare.hxx" #include "util/StringFormat.hxx" @@ -77,9 +78,18 @@ CurlStorage::MapUTF8(const char *uri_utf8) const noexcept if (StringIsEmpty(uri_utf8)) return base; - // TODO: escape the given URI + CurlEasy easy; + std::string path_esc; + + for (auto elt: IterableSplitString(uri_utf8, '/')) { + char *elt_esc = easy.Escape(elt.data, elt.size); + if (!path_esc.empty()) + path_esc.push_back('/'); + path_esc += elt_esc; + curl_free(elt_esc); + } - return PathTraitsUTF8::Build(base.c_str(), uri_utf8); + return PathTraitsUTF8::Build(base.c_str(), path_esc.c_str()); } const char * |