There was an error somewhere in the code when it was extracted from arut/dav-ext-module, perhaps due to the formatter.
This commit is contained in:
@@ -310,8 +310,8 @@ static ngx_int_t ngx_http_dav_ext_content_handler(ngx_http_request_t *r) {
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"http dav_ext propfind");
|
||||
|
||||
rc =
|
||||
ngx_http_read_client_request_body(r, ngx_http_dav_ext_propfind_handler);
|
||||
rc = ngx_http_read_client_request_body(r,
|
||||
ngx_http_dav_ext_propfind_handler);
|
||||
if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
|
||||
return rc;
|
||||
}
|
||||
@@ -458,8 +458,9 @@ static ngx_int_t ngx_http_dav_ext_content_handler(ngx_http_request_t *r) {
|
||||
return NGX_DECLINED;
|
||||
}
|
||||
|
||||
|
||||
static void ngx_http_dav_ext_propfind_handler(ngx_http_request_t *r) {
|
||||
static void
|
||||
ngx_http_dav_ext_propfind_handler(ngx_http_request_t *r)
|
||||
{
|
||||
off_t len;
|
||||
ngx_buf_t *b;
|
||||
ngx_chain_t *cl;
|
||||
@@ -505,8 +506,9 @@ static void ngx_http_dav_ext_propfind_handler(ngx_http_request_t *r) {
|
||||
|
||||
len += b->last - b->pos;
|
||||
|
||||
if (xmlParseChunk(pctx, (const char *)b->pos, b->last - b->pos,
|
||||
b->last_buf)) {
|
||||
if (xmlParseChunk(pctx, (const char *) b->pos, b->last - b->pos,
|
||||
b->last_buf))
|
||||
{
|
||||
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||
"xmlParseChunk() failed");
|
||||
xmlFreeParserCtxt(pctx);
|
||||
@@ -530,10 +532,12 @@ static void ngx_http_dav_ext_propfind_handler(ngx_http_request_t *r) {
|
||||
ngx_http_finalize_request(r, ngx_http_dav_ext_propfind(r, xctx.props));
|
||||
}
|
||||
|
||||
static void ngx_http_dav_ext_propfind_xml_start(
|
||||
void *data, const xmlChar *localname, const xmlChar *prefix,
|
||||
const xmlChar *uri, int nb_namespaces, const xmlChar **namespaces,
|
||||
int nb_attributes, int nb_defaulted, const xmlChar **attributes) {
|
||||
static void
|
||||
ngx_http_dav_ext_propfind_xml_start(void *data, const xmlChar *localname,
|
||||
const xmlChar *prefix, const xmlChar *uri, int nb_namespaces,
|
||||
const xmlChar **namespaces, int nb_attributes, int nb_defaulted,
|
||||
const xmlChar **attributes)
|
||||
{
|
||||
ngx_http_dav_ext_xml_ctx_t *xctx = data;
|
||||
|
||||
if (ngx_strcmp(localname, "propfind") == 0) {
|
||||
@@ -553,10 +557,11 @@ static void ngx_http_dav_ext_propfind_xml_start(
|
||||
}
|
||||
}
|
||||
|
||||
static void ngx_http_dav_ext_propfind_xml_end(void *data,
|
||||
const xmlChar *localname,
|
||||
const xmlChar *prefix,
|
||||
const xmlChar *uri) {
|
||||
|
||||
static void
|
||||
ngx_http_dav_ext_propfind_xml_end(void *data, const xmlChar *localname,
|
||||
const xmlChar *prefix, const xmlChar *uri)
|
||||
{
|
||||
ngx_http_dav_ext_xml_ctx_t *xctx = data;
|
||||
|
||||
if (xctx->nodes & NGX_HTTP_DAV_EXT_NODE_PROPFIND) {
|
||||
@@ -596,12 +601,14 @@ static void ngx_http_dav_ext_propfind_xml_end(void *data,
|
||||
}
|
||||
}
|
||||
|
||||
ngx_http_dav_ext_propfind_xml_start(data, localname, prefix, uri, 0, NULL, 0,
|
||||
0, NULL);
|
||||
ngx_http_dav_ext_propfind_xml_start(data, localname, prefix, uri,
|
||||
0, NULL, 0, 0, NULL);
|
||||
}
|
||||
|
||||
static ngx_int_t ngx_http_dav_ext_propfind(ngx_http_request_t *r,
|
||||
ngx_uint_t props) {
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_dav_ext_propfind(ngx_http_request_t *r, ngx_uint_t props)
|
||||
{
|
||||
size_t root, allocated;
|
||||
u_char *p, *last, *filename;
|
||||
ngx_int_t rc;
|
||||
@@ -613,8 +620,9 @@ static ngx_int_t ngx_http_dav_ext_propfind(ngx_http_request_t *r,
|
||||
ngx_file_info_t fi;
|
||||
ngx_http_dav_ext_entry_t *entry;
|
||||
|
||||
if (ngx_array_init(&entries, r->pool, 40, sizeof(ngx_http_dav_ext_entry_t)) !=
|
||||
NGX_OK) {
|
||||
if (ngx_array_init(&entries, r->pool, 40, sizeof(ngx_http_dav_ext_entry_t))
|
||||
!= NGX_OK)
|
||||
{
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
@@ -639,8 +647,8 @@ static ngx_int_t ngx_http_dav_ext_propfind(ngx_http_request_t *r,
|
||||
|
||||
depth = rc;
|
||||
|
||||
last =
|
||||
ngx_http_map_uri_to_path(r, &path, &root, NGX_HTTP_DAV_EXT_PREALLOCATE);
|
||||
last = ngx_http_map_uri_to_path(r, &path, &root,
|
||||
NGX_HTTP_DAV_EXT_PREALLOCATE);
|
||||
if (last == NULL) {
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
@@ -700,8 +708,8 @@ static ngx_int_t ngx_http_dav_ext_propfind(ngx_http_request_t *r,
|
||||
}
|
||||
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"http dav_ext propfind name:\"%V\", uri:\"%V\"", &entry->name,
|
||||
&entry->uri);
|
||||
"http dav_ext propfind name:\"%V\", uri:\"%V\"",
|
||||
&entry->name, &entry->uri);
|
||||
|
||||
if (depth == 0 || !entry->dir) {
|
||||
return ngx_http_dav_ext_propfind_response(r, &entries, props);
|
||||
@@ -718,7 +726,7 @@ static ngx_int_t ngx_http_dav_ext_propfind(ngx_http_request_t *r,
|
||||
filename = path.data;
|
||||
filename[path.len] = '/';
|
||||
|
||||
for (;;) {
|
||||
for ( ;; ) {
|
||||
ngx_set_errno(0);
|
||||
|
||||
if (ngx_read_dir(&dir) == NGX_ERROR) {
|
||||
@@ -736,8 +744,7 @@ static ngx_int_t ngx_http_dav_ext_propfind(ngx_http_request_t *r,
|
||||
name.len = ngx_de_namelen(&dir);
|
||||
name.data = ngx_de_name(&dir);
|
||||
|
||||
if ((name.len == 1 && name.data[0] == '.') ||
|
||||
(name.len == 2 && name.data[0] == '.' && name.data[1] == '.')) {
|
||||
if (name.data[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -755,7 +762,8 @@ static ngx_int_t ngx_http_dav_ext_propfind(ngx_http_request_t *r,
|
||||
if (!dir.valid_info) {
|
||||
|
||||
if (path.len + 1 + name.len + 1 > allocated) {
|
||||
allocated = path.len + 1 + name.len + 1 + NGX_HTTP_DAV_EXT_PREALLOCATE;
|
||||
allocated = path.len + 1 + name.len + 1
|
||||
+ NGX_HTTP_DAV_EXT_PREALLOCATE;
|
||||
|
||||
filename = ngx_pnalloc(r->pool, allocated);
|
||||
if (filename == NULL) {
|
||||
@@ -770,9 +778,10 @@ static ngx_int_t ngx_http_dav_ext_propfind(ngx_http_request_t *r,
|
||||
ngx_cpystrn(last, name.data, name.len + 1);
|
||||
|
||||
if (ngx_de_info(filename, &dir) == NGX_FILE_ERROR) {
|
||||
ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno,
|
||||
ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
|
||||
ngx_de_info_n " \"%s\" failed", filename);
|
||||
continue;
|
||||
rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -831,10 +840,10 @@ static ngx_int_t ngx_http_dav_ext_propfind(ngx_http_request_t *r,
|
||||
return ngx_http_dav_ext_propfind_response(r, &entries, props);
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t ngx_http_dav_ext_propfind_response(ngx_http_request_t *r,
|
||||
ngx_array_t *entries,
|
||||
ngx_uint_t props) {
|
||||
static ngx_int_t
|
||||
ngx_http_dav_ext_propfind_response(ngx_http_request_t *r, ngx_array_t *entries,
|
||||
ngx_uint_t props)
|
||||
{
|
||||
size_t len;
|
||||
u_char *p;
|
||||
uintptr_t escape;
|
||||
@@ -844,16 +853,18 @@ static ngx_int_t ngx_http_dav_ext_propfind_response(ngx_http_request_t *r,
|
||||
ngx_chain_t cl;
|
||||
ngx_http_dav_ext_entry_t *entry;
|
||||
|
||||
static u_char head[] = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
|
||||
static u_char head[] =
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
|
||||
"<D:multistatus xmlns:D=\"DAV:\">\n";
|
||||
|
||||
static u_char tail[] = "</D:multistatus>\n";
|
||||
static u_char tail[] =
|
||||
"</D:multistatus>\n";
|
||||
|
||||
entry = entries->elts;
|
||||
|
||||
for (n = 0; n < entries->nelts; n++) {
|
||||
escape = 2 * ngx_escape_uri(NULL, entry[n].uri.data, entry[n].uri.len,
|
||||
NGX_ESCAPE_URI_COMPONENT);
|
||||
NGX_ESCAPE_URI);
|
||||
if (escape == 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -863,10 +874,10 @@ static ngx_int_t ngx_http_dav_ext_propfind_response(ngx_http_request_t *r,
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
entry[n].uri.len =
|
||||
(u_char *)ngx_escape_uri(p, entry[n].uri.data, entry[n].uri.len,
|
||||
NGX_ESCAPE_URI_COMPONENT) -
|
||||
p;
|
||||
entry[n].uri.len = (u_char *) ngx_escape_uri(p, entry[n].uri.data,
|
||||
entry[n].uri.len,
|
||||
NGX_ESCAPE_URI)
|
||||
- p;
|
||||
entry[n].uri.data = p;
|
||||
}
|
||||
|
||||
@@ -884,8 +895,8 @@ static ngx_int_t ngx_http_dav_ext_propfind_response(ngx_http_request_t *r,
|
||||
b->last = ngx_cpymem(b->last, head, sizeof(head) - 1);
|
||||
|
||||
for (n = 0; n < entries->nelts; n++) {
|
||||
b->last = (u_char *)ngx_http_dav_ext_format_propfind(r, b->last, &entry[n],
|
||||
props);
|
||||
b->last = (u_char *) ngx_http_dav_ext_format_propfind(r, b->last,
|
||||
&entry[n], props);
|
||||
}
|
||||
|
||||
b->last = ngx_cpymem(b->last, tail, sizeof(tail) - 1);
|
||||
@@ -1255,46 +1266,52 @@ static uint32_t ngx_http_dav_ext_lock_token(ngx_http_request_t *r) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static uintptr_t
|
||||
ngx_http_dav_ext_format_propfind(ngx_http_request_t *r, u_char *dst,
|
||||
ngx_http_dav_ext_entry_t *entry,
|
||||
ngx_uint_t props) {
|
||||
ngx_http_dav_ext_entry_t *entry, ngx_uint_t props)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
static u_char head[] = "<D:response>\n"
|
||||
static u_char head[] =
|
||||
"<D:response>\n"
|
||||
"<D:href>";
|
||||
|
||||
/* uri */
|
||||
|
||||
static u_char prop[] = "</D:href>\n"
|
||||
static u_char prop[] =
|
||||
"</D:href>\n"
|
||||
"<D:propstat>\n"
|
||||
"<D:prop>\n";
|
||||
|
||||
/* properties */
|
||||
|
||||
static u_char tail[] = "</D:prop>\n"
|
||||
static u_char tail[] =
|
||||
"</D:prop>\n"
|
||||
"<D:status>HTTP/1.1 200 OK</D:status>\n"
|
||||
"</D:propstat>\n"
|
||||
"</D:response>\n";
|
||||
|
||||
static u_char names[] = "<D:displayname/>\n"
|
||||
static u_char names[] =
|
||||
"<D:displayname/>\n"
|
||||
"<D:getcontentlength/>\n"
|
||||
"<D:getlastmodified/>\n"
|
||||
"<D:resourcetype/>\n"
|
||||
"<D:lockdiscovery/>\n"
|
||||
"<D:supportedlock/>\n";
|
||||
|
||||
static u_char supportedlock[] = "<D:lockentry>\n"
|
||||
static u_char supportedlock[] =
|
||||
"<D:lockentry>\n"
|
||||
"<D:lockscope><D:exclusive/></D:lockscope>\n"
|
||||
"<D:locktype><D:write/></D:locktype>\n"
|
||||
"</D:lockentry>\n";
|
||||
|
||||
if (dst == NULL) {
|
||||
len = sizeof(head) - 1 + sizeof(prop) - 1 + sizeof(tail) - 1;
|
||||
len = sizeof(head) - 1
|
||||
+ sizeof(prop) - 1
|
||||
+ sizeof(tail) - 1;
|
||||
|
||||
len +=
|
||||
entry->uri.len + ngx_escape_html(NULL, entry->uri.data, entry->uri.len);
|
||||
len += entry->uri.len + ngx_escape_html(NULL, entry->uri.data,
|
||||
entry->uri.len);
|
||||
|
||||
if (props & NGX_HTTP_DAV_EXT_PROP_NAMES) {
|
||||
len += sizeof(names) - 1;
|
||||
@@ -1315,12 +1332,11 @@ ngx_http_dav_ext_format_propfind(ngx_http_request_t *r, u_char *dst,
|
||||
"</D:resourcetype>\n"
|
||||
|
||||
"<D:supportedlock>\n"
|
||||
"</D:supportedlock>\n") -
|
||||
1;
|
||||
"</D:supportedlock>\n") - 1;
|
||||
|
||||
/* displayname */
|
||||
len += entry->name.len +
|
||||
ngx_escape_html(NULL, entry->name.data, entry->name.len);
|
||||
len += entry->name.len
|
||||
+ ngx_escape_html(NULL, entry->name.data, entry->name.len);
|
||||
|
||||
/* getcontentlength */
|
||||
len += NGX_OFF_T_LEN;
|
||||
@@ -1338,7 +1354,7 @@ ngx_http_dav_ext_format_propfind(ngx_http_request_t *r, u_char *dst,
|
||||
}
|
||||
|
||||
dst = ngx_cpymem(dst, head, sizeof(head) - 1);
|
||||
dst = (u_char *)ngx_escape_html(dst, entry->uri.data, entry->uri.len);
|
||||
dst = (u_char *) ngx_escape_html(dst, entry->uri.data, entry->uri.len);
|
||||
dst = ngx_cpymem(dst, prop, sizeof(prop) - 1);
|
||||
|
||||
if (props & NGX_HTTP_DAV_EXT_PROP_NAMES) {
|
||||
@@ -1346,18 +1362,18 @@ ngx_http_dav_ext_format_propfind(ngx_http_request_t *r, u_char *dst,
|
||||
|
||||
} else {
|
||||
if (props & NGX_HTTP_DAV_EXT_PROP_DISPLAYNAME) {
|
||||
dst = ngx_cpymem(dst, "<D:displayname>", sizeof("<D:displayname>") - 1);
|
||||
dst = (u_char *)ngx_escape_html(dst, entry->name.data, entry->name.len);
|
||||
dst = ngx_cpymem(dst, "<D:displayname>",
|
||||
sizeof("<D:displayname>") - 1);
|
||||
dst = (u_char *) ngx_escape_html(dst, entry->name.data,
|
||||
entry->name.len);
|
||||
dst = ngx_cpymem(dst, "</D:displayname>\n",
|
||||
sizeof("</D:displayname>\n") - 1);
|
||||
}
|
||||
|
||||
if (props & NGX_HTTP_DAV_EXT_PROP_GETCONTENTLENGTH) {
|
||||
if (!entry->dir) {
|
||||
dst = ngx_sprintf(dst,
|
||||
"<D:getcontentlength>%O"
|
||||
"</D:getcontentlength>\n",
|
||||
entry->size);
|
||||
dst = ngx_sprintf(dst, "<D:getcontentlength>%O"
|
||||
"</D:getcontentlength>\n", entry->size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1370,10 +1386,12 @@ ngx_http_dav_ext_format_propfind(ngx_http_request_t *r, u_char *dst,
|
||||
}
|
||||
|
||||
if (props & NGX_HTTP_DAV_EXT_PROP_RESOURCETYPE) {
|
||||
dst = ngx_cpymem(dst, "<D:resourcetype>", sizeof("<D:resourcetype>") - 1);
|
||||
dst = ngx_cpymem(dst, "<D:resourcetype>",
|
||||
sizeof("<D:resourcetype>") - 1);
|
||||
|
||||
if (entry->dir) {
|
||||
dst = ngx_cpymem(dst, "<D:collection/>", sizeof("<D:collection/>") - 1);
|
||||
dst = ngx_cpymem(dst, "<D:collection/>",
|
||||
sizeof("<D:collection/>") - 1);
|
||||
}
|
||||
|
||||
dst = ngx_cpymem(dst, "</D:resourcetype>\n",
|
||||
@@ -1381,7 +1399,8 @@ ngx_http_dav_ext_format_propfind(ngx_http_request_t *r, u_char *dst,
|
||||
}
|
||||
|
||||
if (props & NGX_HTTP_DAV_EXT_PROP_LOCKDISCOVERY) {
|
||||
dst = (u_char *)ngx_http_dav_ext_format_lockdiscovery(r, dst, entry);
|
||||
dst = (u_char *) ngx_http_dav_ext_format_lockdiscovery(r, dst,
|
||||
entry);
|
||||
}
|
||||
|
||||
if (props & NGX_HTTP_DAV_EXT_PROP_SUPPORTEDLOCK) {
|
||||
@@ -1399,10 +1418,9 @@ ngx_http_dav_ext_format_propfind(ngx_http_request_t *r, u_char *dst,
|
||||
|
||||
dst = ngx_cpymem(dst, tail, sizeof(tail) - 1);
|
||||
|
||||
return (uintptr_t)dst;
|
||||
return (uintptr_t) dst;
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t ngx_http_dav_ext_init_zone(ngx_shm_zone_t *shm_zone,
|
||||
void *data) {
|
||||
ngx_http_dav_ext_lock_t *olock = data;
|
||||
|
||||
Reference in New Issue
Block a user