MCPcopy Create free account
hub / github.com/apache/httpd / ap_parse_form_data

Function ap_parse_form_data

server/util.c:2787–2937  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2785} ap_form_type_t;
2786
2787AP_DECLARE(int) ap_parse_form_data(request_rec *r, ap_filter_t *f,
2788 apr_array_header_t **ptr,
2789 apr_size_t num, apr_size_t usize)
2790{
2791 apr_bucket_brigade *bb = NULL;
2792 int seen_eos = 0;
2793 char buffer[HUGE_STRING_LEN + 1];
2794 const char *ct;
2795 apr_size_t offset = 0;
2796 apr_ssize_t size;
2797 ap_form_type_t state = FORM_NAME, percent = FORM_NORMAL;
2798 ap_form_pair_t *pair = NULL;
2799 apr_array_header_t *pairs = apr_array_make(r->pool, 4, sizeof(ap_form_pair_t));
2800 char escaped_char[2] = { 0 };
2801
2802 *ptr = pairs;
2803
2804 /* sanity check - we only support forms for now */
2805 ct = apr_table_get(r->headers_in, "Content-Type");
2806 if (!ct || ap_cstr_casecmpn("application/x-www-form-urlencoded", ct, 33)) {
2807 return ap_discard_request_body(r);
2808 }
2809
2810 if (usize > APR_SIZE_MAX >> 1)
2811 size = APR_SIZE_MAX >> 1;
2812 else
2813 size = usize;
2814
2815 if (!f) {
2816 f = r->input_filters;
2817 }
2818
2819 bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
2820 do {
2821 apr_bucket *bucket = NULL, *last = NULL;
2822
2823 int rv = ap_get_brigade(f, bb, AP_MODE_READBYTES,
2824 APR_BLOCK_READ, HUGE_STRING_LEN);
2825 if (rv != APR_SUCCESS) {
2826 apr_brigade_destroy(bb);
2827 return ap_map_http_request_error(rv, HTTP_BAD_REQUEST);
2828 }
2829
2830 for (bucket = APR_BRIGADE_FIRST(bb);
2831 bucket != APR_BRIGADE_SENTINEL(bb);
2832 last = bucket, bucket = APR_BUCKET_NEXT(bucket)) {
2833 const char *data;
2834 apr_size_t len, slide;
2835
2836 if (last) {
2837 apr_bucket_delete(last);
2838 }
2839 if (APR_BUCKET_IS_EOS(bucket)) {
2840 seen_eos = 1;
2841 break;
2842 }
2843 if (bucket->length == 0) {
2844 continue;

Callers 3

get_form_authFunction · 0.85
req_parsebodyFunction · 0.85
example_handlerFunction · 0.85

Calls 5

ap_cstr_casecmpnFunction · 0.85
ap_discard_request_bodyFunction · 0.85
ap_get_brigadeFunction · 0.85
x2cFunction · 0.85

Tested by

no test coverage detected