| 4582 | } |
| 4583 | |
| 4584 | static int dav_method_merge(request_rec *r) |
| 4585 | { |
| 4586 | dav_resource *resource; |
| 4587 | dav_resource *source_resource; |
| 4588 | const dav_hooks_vsn *vsn_hooks = DAV_GET_HOOKS_VSN(r); |
| 4589 | dav_error *err; |
| 4590 | int result; |
| 4591 | apr_xml_doc *doc; |
| 4592 | apr_xml_elem *source_elem; |
| 4593 | apr_xml_elem *href_elem; |
| 4594 | apr_xml_elem *prop_elem; |
| 4595 | const char *source; |
| 4596 | int no_auto_merge; |
| 4597 | int no_checkout; |
| 4598 | dav_lookup_result lookup; |
| 4599 | |
| 4600 | /* If no versioning provider, decline the request */ |
| 4601 | if (vsn_hooks == NULL) |
| 4602 | return DECLINED; |
| 4603 | |
| 4604 | if ((result = ap_xml_parse_input(r, &doc)) != OK) |
| 4605 | return result; |
| 4606 | |
| 4607 | if (doc == NULL || !dav_validate_root(doc, "merge")) { |
| 4608 | /* This supplies additional information for the default msg. */ |
| 4609 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00616) |
| 4610 | "The request body must be present and must be a " |
| 4611 | "DAV:merge element."); |
| 4612 | return HTTP_BAD_REQUEST; |
| 4613 | } |
| 4614 | |
| 4615 | if ((source_elem = dav_find_child(doc->root, "source")) == NULL) { |
| 4616 | /* This supplies additional information for the default msg. */ |
| 4617 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00617) |
| 4618 | "The DAV:merge element must contain a DAV:source " |
| 4619 | "element."); |
| 4620 | return HTTP_BAD_REQUEST; |
| 4621 | } |
| 4622 | if ((href_elem = dav_find_child(source_elem, "href")) == NULL) { |
| 4623 | /* This supplies additional information for the default msg. */ |
| 4624 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00618) |
| 4625 | "The DAV:source element must contain a DAV:href " |
| 4626 | "element."); |
| 4627 | return HTTP_BAD_REQUEST; |
| 4628 | } |
| 4629 | source = dav_xml_get_cdata(href_elem, r->pool, 1 /* strip_white */); |
| 4630 | |
| 4631 | /* get a subrequest for the source, so that we can get a dav_resource |
| 4632 | for that source. */ |
| 4633 | lookup = dav_lookup_uri(source, r, 0 /* must_be_absolute */); |
| 4634 | if (lookup.rnew == NULL) { |
| 4635 | if (lookup.err.status == HTTP_BAD_REQUEST) { |
| 4636 | /* This supplies additional information for the default message. */ |
| 4637 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00619) |
| 4638 | "%s", lookup.err.desc); |
| 4639 | return HTTP_BAD_REQUEST; |
| 4640 | } |
| 4641 |
no test coverage detected