Merge branch 'v0.20.x'

This commit is contained in:
Max Kellermann
2018-08-20 00:19:31 +02:00
19 changed files with 928 additions and 54 deletions

View File

@@ -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;
return PathTraitsUTF8::Build(base.c_str(), uri_utf8);
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(), path_esc.c_str());
}
const char *