summaryrefslogtreecommitdiffhomepage
path: root/src/core/ngx_string.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-06-28Core: escaping of chars not allowed in URIs per RFC 3986.Maxim Dounin1-16/+29
Per RFC 3986 only the following characters are allowed in URIs unescaped: unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" And "%" can appear as a part of escaping itself. The following characters are not allowed and need to be escaped: %00-%1F, %7F-%FF, " ", """, "<", ">", "\", "^", "`", "{", "|", "}". Not escaping ">" is known to cause problems at least with MS Exchange (see http://nginx.org/pipermail/nginx-ru/2010-January/031261.html) and in Tomcat (ticket #2191). The patch adds escaping of the following chars in all URI parts: """, "<", ">", "\", "^", "`", "{", "|", "}". Note that comments are mostly preserved to outline important characters being escaped.
2021-06-28Core: fixed comment about escaping in arguments.Maxim Dounin1-1/+1
After 4954530db2af, the ";" character is escaped by ngx_escape_uri(NGX_ESCAPE_ARGS).
2021-05-19Core: fixed comment about msie_refresh escaping.Ruslan Ermilov1-1/+1
After 12a656452ad1, the "%" character is no longer escaped by ngx_escape_uri(NGX_ESCAPE_REFRESH).
2020-10-28Core: added format specifiers to output binary data as hex.Vladimir Homutov1-19/+68
Now "s", "V", and "v" format specifiers may be prefixed with "x" (lowercase) or "X" (uppercase) to output corresponding data in hexadecimal format. In collaboration with Maxim Dounin.
2019-04-15Fixed incorrect length handling in ngx_utf8_length().Maxim Dounin1-1/+1
Previously, ngx_utf8_decode() was called from ngx_utf8_length() with incorrect length, potentially resulting in out-of-bounds read when handling invalid UTF-8 strings. In practice out-of-bounds reads are not possible though, as autoindex, the only user of ngx_utf8_length(), provides null-terminated strings, and ngx_utf8_decode() anyway returns an errors when it sees a null in the middle of an UTF-8 sequence. Reported by Yunbin Liu.
2018-11-15Core: ngx_explicit_memzero().Maxim Dounin1-0/+8
2017-10-04Fixed handling of non-null-terminated unix sockets.Maxim Dounin1-0/+16
At least FreeBSD, macOS, NetBSD, and OpenBSD can return unix sockets with non-null-terminated sun_path. Additionally, the address may become non-null-terminated if it does not fit into the buffer provided and was truncated (may happen on macOS, NetBSD, and Solaris, which allow unix socket addresess larger than struct sockaddr_un). As such, ngx_sock_ntop() might overread the sockaddr provided, as it used "%s" format and thus assumed null-terminated string. To fix this, the ngx_strnlen() function was introduced, and it is now used to calculate correct length of sun_path.
2017-07-17Parenthesized ASCII-related calculations.Valentin Bartenev1-4/+4
This also fixes potential undefined behaviour in the range and slice filter modules, caused by local overflows of signed integers in expressions.
2017-04-12Core: improved JSON escaping.Valentin Bartenev1-5/+42
Two-character representations are now used for \b, \f, \n, \r, and \t.
2016-07-07Avoid left-shifting integers into the sign bit, which is undefined.Sergey Kandaurov1-2/+2
Found with UndefinedBehaviorSanitizer.
2015-12-03Style: NGX_PTR_SIZE replaced with sizeof(void *).Maxim Dounin1-1/+1
The NGX_PTR_SIZE macro is only needed in preprocessor directives where it's not possible to use sizeof().
2015-03-17Core: overflow detection in number parsing functions.Ruslan Ermilov1-42/+57
2015-01-27A bounds check of %N format on Windows.Igor Sysoev1-1/+5
Thanks to Joe Bialek, Adam Zabrocki and Microsoft Vulnerability Research.
2014-12-12Autoindex: implemented JSON output format.Valentin Bartenev1-0/+52
2014-06-26Core: use uppercase hexadecimal digits for percent-encoding.Piotr Sikora1-1/+1
RFC3986 says that, for consistency, URI producers and normalizers should use uppercase hexadecimal digits for all percent-encodings. This is also what modern web browsers and other tools use. Using lowercase hexadecimal digits makes it harder to interact with those tools in case when use of the percent-encoded URI is required, for example when $request_uri is part of the cache key. Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-02-04Core: added ngx_encode_base64url().Maxim Dounin1-12/+37
2013-09-23Added ngx_filename_cmp() with "/" sorted to the left.Maxim Dounin1-0/+40
This patch fixes incorrect handling of auto redirect in configurations like: location /0 { } location /a- { } location /a/ { proxy_pass ... } With previously used sorting, this resulted in the following locations tree (as "-" is less than "/"): "/a-" "/0" "/a/" and a request to "/a" didn't match "/a/" with auto_redirect, as it didn't traverse relevant tree node during lookup (it tested "/a-", then "/0", and then falled back to null location). To preserve locale use for non-ASCII characters on case-insensetive systems, libc's tolower() used.
2013-09-04Win32: Open Watcom C compatibility fixes.Maxim Dounin1-1/+1
Precompiled headers are disabled as they lead to internal compiler errors with long configure lines. Couple of false positive warnings silenced. Various win32 typedefs are adjusted to work with Open Watcom C 1.9 headers. With this patch, it's now again possible to compile nginx using owc386, with options we normally compile on win32 minus ipv6 and ssl.
2012-08-03Added "const" to ngx_memcpy() with NGX_MEMCPY_LIMIT defined.Maxim Dounin1-1/+1
This fixes warning produced during compilation of the ngx_http_geoip_module due to const qualifier being discarded.
2012-04-23Fix of "%f" format handling.Igor Sysoev1-16/+19
ngx_sprintf("%.2f", 0.999) incorrectly resulted in "0.100" instead of "1.00".
2012-01-18Copyright updated.Maxim Konovalov1-0/+1
2011-11-25Added escaping of double quotes in ngx_escape_html().Maxim Dounin1-0/+9
Patch by Zaur Abasmirzoev.
2011-10-13Fixed utf8 decode (ticket #25).Maxim Dounin1-3/+3
Patch by Alexey Kuts.
2011-10-11Autoindex: escape '?' in file names.Maxim Dounin1-1/+21
For files with '?' in their names autoindex generated links with '?' not escaped. This resulted in effectively truncated links as '?' indicates query string start. This is an updated version of the patch originally posted at [1]. It introduces generic NGX_ESCAPE_URI_COMPONENT which escapes everything but unreserved characters as per RFC 3986. This approach also renders unneeded special colon processing (as colon is percent-encoded now), it's dropped accordingly. [1] http://nginx.org/pipermail/nginx-devel/2010-February/000112.html Reported by Konstantin Leonov.
2011-09-19Replaced "can not" with "cannot" and "could not" in a bunch of places.Ruslan Ermilov1-1/+1
Fixed nearby grammar errors.
2010-09-02new ngx_http_secure_link_module with secure_link, secure_link_md5, andIgor Sysoev1-8/+45
secure_link_expires
2010-07-30escape ";" in argumentsIgor Sysoev1-1/+1
2010-06-23change ngx_http_variable_value_node_t to more generic ngx_str_node_tIgor Sysoev1-0/+83
2010-05-14use ngx_min() and ngx_max()Igor Sysoev1-8/+3
2010-05-14ngx_atofp()Igor Sysoev1-0/+50
2010-05-12fix rounding issues in %f formatIgor Sysoev1-1/+1
2010-05-12use double in %f format to allow %.15f precisionIgor Sysoev1-3/+3
2010-04-01escape ampersand in argument while rewriteIgor Sysoev1-2/+2
2010-01-11fix ngx_utf8_cpystrn(): it did not fully copy utf-8 stringIgor Sysoev1-3/+1
2009-11-02optimize some cycles:Igor Sysoev1-9/+14
*) delete surplus variable; *) on i386/amd64 "while (n) / n--" is smaller than "while (n--)", because the platforms have no postfix operations
2009-09-12If .domain.com, .sub.domain.com, and .domain-some.com were defined,Igor Sysoev1-0/+31
then .sub.domain.com was matched by .domain.com: wildcard names hash was built incorrectly due to sorting order issue of "." vs "-". They were sorted as com.domain com.domain-some com.domain.sub while they should be sorted as com.domain com.domain.sub com.domain-some for correct hash building
2009-09-11style fixIgor Sysoev1-9/+9
2009-08-26fix typoIgor Sysoev1-1/+1
2009-06-05change surplus for() to while()Igor Sysoev1-1/+4
2009-04-27ngx_vslprintf(), ngx_slprintf()Igor Sysoev1-10/+18
2009-04-06backout r2677 and fix ngx_strlcasestrn() againIgor Sysoev1-5/+1
2009-04-06fix ngx_strlcasestrn()Igor Sysoev1-0/+4
2009-04-04ngx_strlcasestrn()Igor Sysoev1-0/+33
2008-11-10%f formatIgor Sysoev1-63/+137
2008-08-04ngx_strlow()Igor Sysoev1-0/+11
2008-07-29rename ngx_utf_...() to ngx_utf8_...()Igor Sysoev1-8/+8
2008-07-25fix utf-8 names in autoindexIgor Sysoev1-26/+30
2008-06-17*) back out r2040Igor Sysoev1-1/+1
*) refactor ngx_palloc() *) introduce ngx_pnalloc() *) additional pool blocks have smaller header
2008-03-24use ngx_int_t in ngx_sort() callbackIgor Sysoev1-1/+1
2008-03-23use dynamically allocated buffer in ngx_sort()Igor Sysoev1-5/+11