Klaus Demo nginx / 1dcaa97
refactor ngx_http_arg() using ngx_strcasestrn(), back out zero termination introduced in r2138 Igor Sysoev 13 years ago
2 changed file(s) with 10 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
14851485 ngx_int_t
14861486 ngx_http_arg(ngx_http_request_t *r, u_char *name, size_t len, ngx_str_t *value)
14871487 {
1488 u_char *p;
1488 u_char *p, *last;
14891489
14901490 if (r->args.len == 0) {
14911491 return NGX_DECLINED;
14921492 }
14931493
1494 for (p = r->args.data; *p && *p != ' '; p++) {
1495
1496 /*
1497 * although r->args.data is not null-terminated by itself,
1498 * however, there is null in the end of request line
1499 */
1500
1501 p = ngx_strcasestrn(p, (char *) name, len - 1);
1494 p = r->args.data;
1495 last = p + r->args.len;
1496
1497 for ( /* void */ ; p < last; p++) {
1498
1499 /* we need '=' after name, so drop one char from last */
1500
1501 p = ngx_strlcasestrn(p, last - 1, name, len - 1);
15021502
15031503 if (p == NULL) {
15041504 return NGX_DECLINED;
15081508
15091509 value->data = p + len + 1;
15101510
1511 p = (u_char *) ngx_strchr(p, '&');
1511 p = ngx_strlchr(p, last, '&');
15121512
15131513 if (p == NULL) {
15141514 p = r->args.data + r->args.len;
696696
697697 r->request_line.len = r->request_end - r->request_start;
698698 r->request_line.data = r->request_start;
699 *r->request_end = '\0';
700699
701700
702701 if (r->args_start) {