[Oisf-devel] libhtp - Normalization of query string

Anoop Saldanha anoopsaldanha at gmail.com
Mon Jun 17 08:25:09 UTC 2013


On Mon, Jun 17, 2013 at 1:48 PM, Anoop Saldanha <anoopsaldanha at gmail.com> wrote:
> While producing the normalized uri, what is the right way to
> generate the normalized query string? Can see 2 solutions -
>
>     1. Duplicate this code section from htp_unparse_uri_noencode( ) -
>
>         if (uri->query != NULL) {
>             bstr *query = bstr_dup(uri->query);
>             htp_uriencoding_normalize_inplace(query);
>             bstr_add_c_noex(r, "?");
>             bstr_add_noex(r, query);
>             bstr_free(query);
>         }
>
>     2. Register htp_config_register_urlencoded_parser( ), and then
>           use the below code -
>
>         if (uri->query != NULL) {
>             bstr_add_c_noex(r, "?");
>             size_t tsize = htp_table_size(tx->request_params);
>             size_t i;
>             for (i = 0; i < tsize; i++) {
>                 htp_param_t *p =
>                     htp_table_get_index(tx->request_params, i, NULL);
>                 if (p == NULL || p->source != HTP_SOURCE_QUERY_STRING)
>                     continue;
>                 bstr_add_noex(r, p->name);
>                 if (bstr_len(p->value) != 0) {
>                     bstr_add_c_noex(r, "=");
>                     bstr_add_noex(r, p->value);
>                 }
>                 if (i != (tsize - 1))
>                     bstr_add_c_noex(r, "&");
>         }
>
>     Which of these 2 is the right solution?
>

P.S: I have also asked the above question in the mail thread - "libhtp
0.5.x integration - bug 775" on oisf-devel.  Please ignore that.

-- 
-------------------------------
Anoop Saldanha
http://www.poona.me
-------------------------------



More information about the Oisf-devel mailing list