Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
216f62ea
Unverified
Commit
216f62ea
authored
Jan 04, 2021
by
Vincent Petry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Webdav href in response can be relative
Fixed Webdav base path stripping in cases where href is a relative path. Signed-off-by:
Vincent Petry
<
PVince81@yahoo.fr
>
parent
b7d00013
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
8 deletions
+25
-8
CurlStorage.cxx
src/storage/plugins/CurlStorage.cxx
+25
-8
No files found.
src/storage/plugins/CurlStorage.cxx
View file @
216f62ea
...
...
@@ -468,11 +468,19 @@ CurlStorage::GetInfo(std::string_view uri_utf8, [[maybe_unused]] bool follow)
gcc_pure
static
std
::
string_view
UriPathOrSlash
(
const
char
*
uri
)
noexcept
UriPathOrSlash
(
const
char
*
uri
,
bool
relative
)
noexcept
{
auto
path
=
uri_get_path
(
uri
);
if
(
path
.
data
()
==
nullptr
)
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
;
}
...
...
@@ -481,13 +489,15 @@ UriPathOrSlash(const char *uri) noexcept
*/
class
HttpListDirectoryOperation
final
:
public
PropfindOperation
{
const
std
::
string
base_path
;
const
std
::
string
base_path_relative
;
MemoryStorageDirectoryReader
::
List
entries
;
public
:
HttpListDirectoryOperation
(
CurlGlobal
&
curl
,
const
char
*
uri
)
:
PropfindOperation
(
curl
,
uri
,
1
),
base_path
(
CurlUnescape
(
GetEasy
(),
UriPathOrSlash
(
uri
)))
{}
base_path
(
CurlUnescape
(
GetEasy
(),
UriPathOrSlash
(
uri
,
false
))),
base_path_relative
(
CurlUnescape
(
GetEasy
(),
UriPathOrSlash
(
uri
,
true
)))
{}
std
::
unique_ptr
<
StorageDirectoryReader
>
Perform
()
{
DeferStart
();
...
...
@@ -506,6 +516,7 @@ private:
*/
gcc_pure
StringView
HrefToEscapedName
(
const
char
*
href
)
const
noexcept
{
StringView
relative_path
;
StringView
path
=
uri_get_path
(
href
);
if
(
path
==
nullptr
)
return
nullptr
;
...
...
@@ -513,17 +524,23 @@ private:
/* kludge: ignoring case in this comparison to avoid
false negatives if the web server uses a different
case */
path
=
StringAfterPrefixIgnoreCase
(
path
,
base_path
.
c_str
());
if
(
path
==
nullptr
||
path
.
empty
())
relative_path
=
StringAfterPrefixIgnoreCase
(
path
,
base_path
.
c_str
());
if
(
relative_path
==
nullptr
||
relative_path
.
empty
())
{
// try relative base path
relative_path
=
StringAfterPrefixIgnoreCase
(
path
,
base_path_relative
.
c_str
());
}
if
(
relative_path
==
nullptr
||
relative_path
.
empty
())
{
return
nullptr
;
}
const
char
*
slash
=
path
.
Find
(
'/'
);
const
char
*
slash
=
relative_
path
.
Find
(
'/'
);
if
(
slash
==
nullptr
)
/* regular file */
return
path
;
else
if
(
slash
==
&
path
.
back
())
return
relative_
path
;
else
if
(
slash
==
&
relative_
path
.
back
())
/* trailing slash: collection; strip the slash */
return
{
path
.
data
,
slash
};
return
{
relative_
path
.
data
,
slash
};
else
/* strange, better ignore it */
return
nullptr
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment