Use uri_has_scheme for Webdav response href
Use uri_has_scheme to find out if the href in Webdav responses is absolute to use the matching base path extraction. Signed-off-by: Vincent Petry <PVince81@yahoo.fr>
This commit is contained in:
parent
216f62ea14
commit
74b2fc7fdc
@ -516,7 +516,6 @@ private:
|
|||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
StringView HrefToEscapedName(const char *href) const noexcept {
|
StringView HrefToEscapedName(const char *href) const noexcept {
|
||||||
StringView relative_path;
|
|
||||||
StringView path = uri_get_path(href);
|
StringView path = uri_get_path(href);
|
||||||
if (path == nullptr)
|
if (path == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -524,23 +523,23 @@ 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 */
|
||||||
relative_path = StringAfterPrefixIgnoreCase(path, base_path.c_str());
|
if (uri_has_scheme(path)) {
|
||||||
if (relative_path == nullptr || relative_path.empty()) {
|
path = StringAfterPrefixIgnoreCase(path, base_path.c_str());
|
||||||
// try relative base path
|
} else {
|
||||||
relative_path = StringAfterPrefixIgnoreCase(path, base_path_relative.c_str());
|
path = StringAfterPrefixIgnoreCase(path, base_path_relative.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (relative_path == nullptr || relative_path.empty()) {
|
if (path == nullptr || path.empty()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *slash = relative_path.Find('/');
|
const char *slash = path.Find('/');
|
||||||
if (slash == nullptr)
|
if (slash == nullptr)
|
||||||
/* regular file */
|
/* regular file */
|
||||||
return relative_path;
|
return path;
|
||||||
else if (slash == &relative_path.back())
|
else if (slash == &path.back())
|
||||||
/* trailing slash: collection; strip the slash */
|
/* trailing slash: collection; strip the slash */
|
||||||
return {relative_path.data, slash};
|
return {path.data, slash};
|
||||||
else
|
else
|
||||||
/* strange, better ignore it */
|
/* strange, better ignore it */
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -85,7 +85,7 @@ uri_after_scheme(std::string_view uri) noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
uri_has_scheme(const char *uri) noexcept
|
uri_has_scheme(std::string_view uri) noexcept
|
||||||
{
|
{
|
||||||
return !uri_get_scheme(uri).empty();
|
return !uri_get_scheme(uri).empty();
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
bool
|
bool
|
||||||
uri_has_scheme(const char *uri) noexcept;
|
uri_has_scheme(std::string_view uri) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the scheme name of the specified URI, or an empty string.
|
* Returns the scheme name of the specified URI, or an empty string.
|
||||||
|
Loading…
Reference in New Issue
Block a user