dav_process_if_header: * * If NULL (no error) is returned, then **if_header points to the * "If" productions structure (or NULL if "If" is not present). * * ### this part is bogus: * If an error is encountered, the error is logged. Parent should * return err->status. */
| 667 | * return err->status. |
| 668 | */ |
| 669 | static dav_error * dav_process_if_header(request_rec *r, dav_if_header **p_ih) |
| 670 | { |
| 671 | dav_error *err; |
| 672 | char *str; |
| 673 | char *list; |
| 674 | const char *state_token; |
| 675 | const char *uri = NULL; /* scope of current production; NULL=no-tag */ |
| 676 | apr_size_t uri_len = 0; |
| 677 | apr_status_t rv; |
| 678 | dav_if_header *ih = NULL; |
| 679 | apr_uri_t parsed_uri; |
| 680 | const dav_hooks_locks *locks_hooks = DAV_GET_HOOKS_LOCKS(r); |
| 681 | enum {no_tagged, tagged, unknown} list_type = unknown; |
| 682 | int condition; |
| 683 | |
| 684 | *p_ih = NULL; |
| 685 | |
| 686 | if ((str = apr_pstrdup(r->pool, apr_table_get(r->headers_in, "If"))) == NULL) |
| 687 | return NULL; |
| 688 | |
| 689 | while (*str) { |
| 690 | switch(*str) { |
| 691 | case '<': |
| 692 | /* Tagged-list production - following states apply to this uri */ |
| 693 | if (list_type == no_tagged |
| 694 | || ((uri = dav_fetch_next_token(&str, '>')) == NULL)) { |
| 695 | return dav_new_error(r->pool, HTTP_BAD_REQUEST, |
| 696 | DAV_ERR_IF_TAGGED, 0, |
| 697 | "Invalid If-header: unclosed \"<\" or " |
| 698 | "unexpected tagged-list production."); |
| 699 | } |
| 700 | |
| 701 | /* 2518 specifies this must be an absolute URI; just take the |
| 702 | * relative part for later comparison against r->uri */ |
| 703 | if ((rv = apr_uri_parse(r->pool, uri, &parsed_uri)) != APR_SUCCESS |
| 704 | || !parsed_uri.path) { |
| 705 | return dav_new_error(r->pool, HTTP_BAD_REQUEST, |
| 706 | DAV_ERR_IF_TAGGED, rv, |
| 707 | "Invalid URI in tagged If-header."); |
| 708 | } |
| 709 | /* note that parsed_uri.path is allocated; we can trash it */ |
| 710 | |
| 711 | /* clean up the URI a bit */ |
| 712 | if (!ap_normalize_path(parsed_uri.path, |
| 713 | AP_NORMALIZE_NOT_ABOVE_ROOT | |
| 714 | AP_NORMALIZE_DECODE_UNRESERVED)) { |
| 715 | return dav_new_error(r->pool, HTTP_BAD_REQUEST, |
| 716 | DAV_ERR_IF_TAGGED, rv, |
| 717 | "Invalid URI path tagged If-header."); |
| 718 | } |
| 719 | |
| 720 | /* the resources we will compare to have unencoded paths */ |
| 721 | if (ap_unescape_url(parsed_uri.path) != OK) { |
| 722 | return dav_new_error(r->pool, HTTP_BAD_REQUEST, |
| 723 | DAV_ERR_IF_TAGGED, rv, |
| 724 | "Invalid percent encoded URI in " |
| 725 | "tagged If-header."); |
| 726 | } |
no test coverage detected