aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_parse.c
Commit message (Collapse)AuthorAge
* Proxy: proxy_pass_trailers directive.Sergey Kandaurov2024-09-13
| | | | The directive allows to pass upstream response trailers to client.
* HTTP: removed unused r->port_start and r->port_end.Vladimir Khomutov2023-11-28
| | | | | | | | Neither r->port_start nor r->port_end were ever used. The r->port_end is set by the parser, though it was never used by the following code (and was never usable, since not copied by the ngx_http_alloc_large_header_buffer() without r->port_start set).
* Reworked multi headers to use linked lists.Maxim Dounin2022-05-30
| | | | | | | | | | | | | | | | | Multi headers are now using linked lists instead of arrays. Notably, the following fields were changed: r->headers_in.cookies (renamed to r->headers_in.cookie), r->headers_in.x_forwarded_for, r->headers_out.cache_control, r->headers_out.link, u->headers_in.cache_control u->headers_in.cookies (renamed to u->headers_in.set_cookie). The r->headers_in.cookies and u->headers_in.cookies fields were renamed to r->headers_in.cookie and u->headers_in.set_cookie to match header names. The ngx_http_parse_multi_header_lines() and ngx_http_parse_set_cookie_lines() functions were changed accordingly. With this change, multi headers are now essentially equivalent to normal headers, and following changes will further make them equivalent.
* Improved logging of invalid headers.Maxim Dounin2021-06-28
| | | | | | | | | | | | | | In 71edd9192f24 logging of invalid headers which were rejected with the NGX_HTTP_PARSE_INVALID_HEADER error was restricted to just the "client sent invalid header line" message, without any attempts to log the header itself. This patch returns logging of the header up to the invalid character and the character itself. The r->header_end pointer is now properly set in all cases to make logging possible. The same logging is also introduced when parsing headers from upstream servers.
* Disabled control characters and space in header names.Maxim Dounin2021-06-28
| | | | | | | | | | | | | | Control characters (0x00-0x1f, 0x7f), space, and colon were never allowed in header names. The only somewhat valid use is header continuation which nginx never supported and which is explicitly obsolete by RFC 7230. Previously, such headers were considered invalid and were ignored by default (as per ignore_invalid_headers directive). With this change, such headers are unconditionally rejected. It is expected to make nginx more resilient to various attacks, in particular, with ignore_invalid_headers switched off (which is inherently unsecure, though nevertheless sometimes used in the wild).
* Disabled control characters in URIs.Maxim Dounin2021-06-28
| | | | | | | | Control characters (0x00-0x1f, 0x7f) were never allowed in URIs, and must be percent-encoded by clients. Further, these are not believed to appear in practice. On the other hand, passing such characters might make various attacks possible or easier, despite the fact that currently allowed control characters are not significant for HTTP request parsing.
* Disabled spaces in URIs (ticket #196).Maxim Dounin2021-06-28
| | | | | | | From now on, requests with spaces in URIs are immediately rejected rather than allowed. Spaces were allowed in 31e9677b15a1 (0.8.41) to handle bad clients. It is believed that now this behaviour causes more harm than good.
* Added CONNECT method rejection.Maxim Dounin2021-06-28
| | | | | | | | | No valid CONNECT requests are expected to appear within nginx, since it is not a forward proxy. Further, request line parsing will reject proper CONNECT requests anyway, since we don't allow authority-form of request-target. On the other hand, RFC 7230 specifies separate message length rules for CONNECT which we don't support, so make sure to always reject CONNECTs to avoid potential abuse.
* Fixed parsing of absolute URIs with empty path (ticket #2079).Maxim Dounin2020-12-10
| | | | | | | | | | | | | | | When the request line contains request-target in the absolute-URI form, it can contain path-empty instead of a single slash (see RFC 7230, RFC 3986). Previously, the ngx_http_parse_request_line() function only accepted empty path when there was no query string. With this change, non-empty query is also correctly handled. That is, request line "GET http://example.com?foo HTTP/1.1" is accepted and results in $uri "/" and $args "foo". Note that $request_uri remains "?foo", similarly to how spaces in URIs are handled. Providing "/?foo", similarly to how "/" is provided for "GET http://example.com HTTP/1.1", requires allocation.
* Fixed header parsing with ignore_invalid_headers switched off.Ruslan Ermilov2019-10-15
| | | | | | The parsing was broken when the first character of the header name was invalid. Based on a patch by Alan Kemp.
* Fixed URI normalization with merge_slashes switched off.Maxim Dounin2019-10-08
| | | | | Previously, "/foo///../bar" was normalized into "/foo/bar" instead of "/foo//bar".
* The "/." and "/.." at the end of URI should be normalized.Ruslan Ermilov2019-10-08
|
* Improved detection of broken percent encoding in URI.Ruslan Ermilov2019-10-08
|
* Detect runaway chunks in ngx_http_parse_chunked().Sergey Kandaurov2019-09-03
| | | | | | | | | | | | | | | | | As defined in HTTP/1.1, body chunks have the following ABNF: chunk = chunk-size [ chunk-ext ] CRLF chunk-data CRLF where chunk-data is a sequence of chunk-size octets. With this change, chunk-data that doesn't end up with CRLF at chunk-size offset will be treated as invalid, such as in the example provided below: 4 SEE-THIS-AND- 4 THAT 0
* Allowed digits, '+', '-', and '.' in scheme names as per RFC 3986.Ruslan Ermilov2018-05-24
|
* Parenthesized ASCII-related calculations.Valentin Bartenev2017-07-17
| | | | | This also fixes potential undefined behaviour in the range and slice filter modules, caused by local overflows of signed integers in expressions.
* Added missing "fall through" comments (ticket #1259).Maxim Dounin2017-04-27
| | | | Found by gcc7 (-Wimplicit-fallthrough).
* Don't pretend we support HTTP major versions >1 as HTTP/1.1.Ruslan Ermilov2017-04-25
|
* Allowed '-' in method names.Maxim Dounin2016-10-10
| | | | | | It is used at least by SOAP (M-POST method, defined by RFC 2774) and by WebDAV versioning (VERSION-CONTROL and BASELINE-CONTROL methods, defined by RFC 3253).
* Avoid left-shifting integers into the sign bit, which is undefined.Sergey Kandaurov2016-07-07
| | | | Found with UndefinedBehaviorSanitizer.
* Added overflow checks for version numbers (ticket #762).Maxim Dounin2016-05-18
| | | | | | | | Both minor and major versions are now limited to 999 maximum. In case of r->http_minor, this limit is already implied by the code. Major version, r->http_major, in theory can be up to 65535 with current code, but such values are very unlikely to become real (and, additionally, such values are not allowed by RFC 7230), so the same test was used for r->http_major.
* Overflow detection in ngx_http_parse_chunked().Ruslan Ermilov2015-03-17
|
* Style: add whitespace between control statement and parentheses.Piotr Sikora2014-07-08
| | | | Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
* Upstream: added the "$upstream_cookie_<name>" variables.Vladimir Homutov2014-04-29
|
* Apply underscores_in_headers also to the first character.Piotr Sikora2014-03-24
| | | | Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
* Teach ngx_http_parse_unsafe_uri() how to unescape URIs.Ruslan Ermilov2013-12-23
| | | | | This fixes handling of escaped URIs in X-Accel-Redirect (ticket #316), SSI (ticket #240), and DAV.
* Detect more unsafe URIs in ngx_http_parse_unsafe_uri().Ruslan Ermilov2013-12-23
| | | | The following URIs were considered safe: "..", "../foo", and "/foo/..".
* Proper backtracking after space in a request line.Ruslan Ermilov2013-11-19
|
* Minor ngx_http_parse_request_line() optimization.Maxim Dounin2013-08-21
| | | | Noted by Nils Kuhnhenn.
* Fixed ngx_http_parse_chunked() minimal length calculation.Maxim Dounin2013-06-28
| | | | | | | | Minimal data length we expect for further calls was calculated incorrectly if parsing stopped right after parsing chunk size. This might in theory affect clients and/or backends using LF instead of CRLF. Patch by Dmitry Popov.
* Fixed debug logging in ngx_http_parse_complex_uri().Maxim Dounin2013-06-05
| | | | | The *u previously logged isn't yet initialized at this point, and Valgrind complains.
* Fixed chunk size parsing.Maxim Dounin2013-05-06
|
* Preliminary experimental support for SPDY draft 2.Valentin Bartenev2013-03-20
|
* Request body: adjust b->pos when chunked parsing done.Maxim Dounin2012-11-21
| | | | | This is a nop for the current code, though will allow to correctly parse pipelined requests.
* Request body: chunked parsing moved to ngx_http_parse.c from proxy.Maxim Dounin2012-11-21
| | | | No functional changes.
* Win32: normalization of trailing dot inside uri.Maxim Dounin2012-06-05
| | | | | | | Windows treats "/directory./" identical to "/directory/". Do the same when working on Windows. Note that the behaviour is different from one with last path component (where multiple spaces and dots are ignored by Windows).
* Fixed spelling in multiline C comments.Ruslan Ermilov2012-04-03
|
* For the sake of case/switch code readability, 'fall through'Maxim Konovalov2012-03-19
| | | | comments added.
* Headers with null character are now rejected.Maxim Dounin2012-03-15
| | | | | Headers with NUL character aren't allowed by HTTP standard and may cause various security problems. They are now unconditionally rejected.
* Copyright updated.Maxim Konovalov2012-01-18
|
* Added support for IP-literal in the Host header and request line (ticket #1).Valentin Bartenev2011-11-28
| | | | | | | | | | | | | | | | | | | | Additional parsing logic added to correctly handle RFC 3986 compliant IPv6 and IPvFuture characters enclosed in square brackets. The host validation was completely rewritten. The behavior for non IP literals was changed in a more proper and safer way: - Host part is now delimited either by the first colon or by the end of string if there's no colon. Previously the last colon was used as delimiter which allowed substitution of a port number in the $host variable. (e.g. Host: 127.0.0.1:9000:80) - Fixed stripping of the ending dot in the Host header when the host was also followed by a port number. (e.g. Host: nginx.com.:80) - Fixed upper case characters detection. Previously it was broken which led to wasting memory and CPU.
* Protocol version parsing in ngx_http_parse_status_line().Maxim Dounin2011-09-15
| | | | | Once we know protocol version, set u->headers_in.connection_close to indicate implicitly assumed connection close with HTTP before 1.1.
* style fixIgor Sysoev2010-06-23
|
* ngx_http_parse_status_line()Igor Sysoev2010-06-15
|
* allow spaces in URIIgor Sysoev2010-06-15
|
* PATCH methodIgor Sysoev2010-06-10
|
* fix "/dir/%3F../" and "/dir/%23../" casesIgor Sysoev2010-06-04
|
* remove r->zero_in_uriIgor Sysoev2010-05-24
|
* check unsafe DestinationIgor Sysoev2009-09-25
|
* handle "/../" case more reliablyIgor Sysoev2009-09-14
|