Merge branch 'bugfix/1043/remove-basepath-handling' of git://github.com/PVince81/MPD into v0.22.x
This commit is contained in:
commit
ec1e04a65d
@ -468,19 +468,11 @@ CurlStorage::GetInfo(std::string_view uri_utf8, [[maybe_unused]] bool follow)
|
|||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
static std::string_view
|
static std::string_view
|
||||||
UriPathOrSlash(const char *uri, bool relative) noexcept
|
UriPathOrSlash(const char *uri) noexcept
|
||||||
{
|
{
|
||||||
auto path = uri_get_path(uri);
|
auto path = uri_get_path(uri);
|
||||||
if (path.data() == nullptr)
|
if (path.data() == nullptr)
|
||||||
path = "/";
|
path = "/";
|
||||||
else if (relative) {
|
|
||||||
// search after first slash
|
|
||||||
path = path.substr(1);
|
|
||||||
auto slash = path.find('/');
|
|
||||||
if (slash != std::string_view::npos)
|
|
||||||
path = path.substr(slash);
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -489,15 +481,13 @@ UriPathOrSlash(const char *uri, bool relative) noexcept
|
|||||||
*/
|
*/
|
||||||
class HttpListDirectoryOperation final : public PropfindOperation {
|
class HttpListDirectoryOperation final : public PropfindOperation {
|
||||||
const std::string base_path;
|
const std::string base_path;
|
||||||
const std::string base_path_relative;
|
|
||||||
|
|
||||||
MemoryStorageDirectoryReader::List entries;
|
MemoryStorageDirectoryReader::List entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HttpListDirectoryOperation(CurlGlobal &curl, const char *uri)
|
HttpListDirectoryOperation(CurlGlobal &curl, const char *uri)
|
||||||
:PropfindOperation(curl, uri, 1),
|
:PropfindOperation(curl, uri, 1),
|
||||||
base_path(CurlUnescape(GetEasy(), UriPathOrSlash(uri, false))),
|
base_path(CurlUnescape(GetEasy(), UriPathOrSlash(uri))) {}
|
||||||
base_path_relative(CurlUnescape(GetEasy(), UriPathOrSlash(uri, true))) {}
|
|
||||||
|
|
||||||
std::unique_ptr<StorageDirectoryReader> Perform() {
|
std::unique_ptr<StorageDirectoryReader> Perform() {
|
||||||
DeferStart();
|
DeferStart();
|
||||||
@ -523,15 +513,9 @@ 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 */
|
case */
|
||||||
if (uri_has_scheme(path)) {
|
path = StringAfterPrefixIgnoreCase(path, base_path.c_str());
|
||||||
path = StringAfterPrefixIgnoreCase(path, base_path.c_str());
|
if (path == nullptr || path.empty())
|
||||||
} else {
|
|
||||||
path = StringAfterPrefixIgnoreCase(path, base_path_relative.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path == nullptr || path.empty()) {
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
|
||||||
|
|
||||||
const char *slash = path.Find('/');
|
const char *slash = path.Find('/');
|
||||||
if (slash == nullptr)
|
if (slash == nullptr)
|
||||||
|
Loading…
Reference in New Issue
Block a user