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
81ea7492
Commit
81ea7492
authored
Jan 05, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v0.22.x'
parents
e009ad1a
e99f6b5b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
18 deletions
+49
-18
NEWS
NEWS
+2
-0
CurlStorage.cxx
src/storage/plugins/CurlStorage.cxx
+45
-16
UriExtract.cxx
src/util/UriExtract.cxx
+1
-1
UriExtract.hxx
src/util/UriExtract.hxx
+1
-1
No files found.
NEWS
View file @
81ea7492
...
...
@@ -3,6 +3,8 @@ ver 0.23 (not yet released)
- new command "getvol"
ver 0.22.4 (not yet released)
* storage
- curl: fix several WebDAV protocol bugs
* decoder
- dsdiff: apply padding to odd-sized chunks
* filter
...
...
src/storage/plugins/CurlStorage.cxx
View file @
81ea7492
...
...
@@ -243,6 +243,7 @@ class PropfindOperation : BlockingHttpRequest, CommonExpatParser {
enum
class
State
{
ROOT
,
RESPONSE
,
PROPSTAT
,
HREF
,
STATUS
,
TYPE
,
...
...
@@ -262,18 +263,19 @@ public:
request
.
SetOption
(
CURLOPT_MAXREDIRS
,
1L
);
request_headers
.
Append
(
StringFormat
<
40
>
(
"depth: %u"
,
depth
));
request_headers
.
Append
(
"content-type: text/xml"
);
request
.
SetOption
(
CURLOPT_HTTPHEADER
,
request_headers
.
Get
());
request
.
SetOption
(
CURLOPT_POSTFIELDS
,
"<?xml version=
\"
1.0
\"
?>
\n
"
"<a:propfind xmlns:a=
\"
DAV:
\"
>"
"<a:prop><a:resourcetype/></a:prop>"
"<a:prop><a:getcontenttype/></a:prop>"
"<a:prop><a:getcontentlength/></a:prop>"
"<a:prop>"
"<a:resourcetype/>"
"<a:getcontenttype/>"
"<a:getcontentlength/>"
"</a:prop>"
"</a:propfind>"
);
// TODO: send request body
}
using
BlockingHttpRequest
::
GetEasy
;
...
...
@@ -321,9 +323,13 @@ private:
break
;
case
State
:
:
RESPONSE
:
if
(
strcmp
(
name
,
"DAV:|href"
)
==
0
)
if
(
strcmp
(
name
,
"DAV:|propstat"
)
==
0
)
state
=
State
::
PROPSTAT
;
else
if
(
strcmp
(
name
,
"DAV:|href"
)
==
0
)
state
=
State
::
HREF
;
else
if
(
strcmp
(
name
,
"DAV:|status"
)
==
0
)
break
;
case
State
:
:
PROPSTAT
:
if
(
strcmp
(
name
,
"DAV:|status"
)
==
0
)
state
=
State
::
STATUS
;
else
if
(
strcmp
(
name
,
"DAV:|resourcetype"
)
==
0
)
state
=
State
::
TYPE
;
...
...
@@ -353,9 +359,15 @@ private:
case
State
:
:
RESPONSE
:
if
(
strcmp
(
name
,
"DAV:|response"
)
==
0
)
{
FinishResponse
();
state
=
State
::
ROOT
;
}
break
;
case
State
:
:
PROPSTAT
:
if
(
strcmp
(
name
,
"DAV:|propstat"
)
==
0
)
{
FinishResponse
();
state
=
State
::
RESPONSE
;
}
break
;
...
...
@@ -366,22 +378,22 @@ private:
case
State
:
:
STATUS
:
if
(
strcmp
(
name
,
"DAV:|status"
)
==
0
)
state
=
State
::
RESPONSE
;
state
=
State
::
PROPSTAT
;
break
;
case
State
:
:
TYPE
:
if
(
strcmp
(
name
,
"DAV:|resourcetype"
)
==
0
)
state
=
State
::
RESPONSE
;
state
=
State
::
PROPSTAT
;
break
;
case
State
:
:
MTIME
:
if
(
strcmp
(
name
,
"DAV:|getlastmodified"
)
==
0
)
state
=
State
::
RESPONSE
;
state
=
State
::
PROPSTAT
;
break
;
case
State
:
:
LENGTH
:
if
(
strcmp
(
name
,
"DAV:|getcontentlength"
)
==
0
)
state
=
State
::
RESPONSE
;
state
=
State
::
PROPSTAT
;
break
;
}
}
...
...
@@ -389,6 +401,7 @@ private:
void
CharacterData
(
const
XML_Char
*
s
,
int
len
)
final
{
switch
(
state
)
{
case
State
:
:
ROOT
:
case
State
:
:
PROPSTAT
:
case
State
:
:
RESPONSE
:
case
State
:
:
TYPE
:
break
;
...
...
@@ -455,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
;
}
...
...
@@ -468,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
();
...
...
@@ -500,9 +523,15 @@ 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
())
if
(
uri_has_scheme
(
path
))
{
path
=
StringAfterPrefixIgnoreCase
(
path
,
base_path
.
c_str
());
}
else
{
path
=
StringAfterPrefixIgnoreCase
(
path
,
base_path_relative
.
c_str
());
}
if
(
path
==
nullptr
||
path
.
empty
())
{
return
nullptr
;
}
const
char
*
slash
=
path
.
Find
(
'/'
);
if
(
slash
==
nullptr
)
...
...
src/util/UriExtract.cxx
View file @
81ea7492
...
...
@@ -85,7 +85,7 @@ uri_after_scheme(std::string_view uri) noexcept
}
bool
uri_has_scheme
(
const
char
*
uri
)
noexcept
uri_has_scheme
(
std
::
string_view
uri
)
noexcept
{
return
!
uri_get_scheme
(
uri
).
empty
();
}
...
...
src/util/UriExtract.hxx
View file @
81ea7492
...
...
@@ -40,7 +40,7 @@
*/
gcc_pure
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.
...
...
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