summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_http_parse.c
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2019-09-16 20:17:42 +0300
committerValentin Bartenev <vbart@nginx.com>2019-09-16 20:17:42 +0300
commit64be8717bdc2f0f8f11cbb8d18a0f96d2c24c6d3 (patch)
tree1539675a0756c9356719fd6b679eabea840983dc /src/nxt_http_parse.c
parentb5394c39568d9895d5c84862e7a209b76f98bea9 (diff)
downloadunit-64be8717bdc2f0f8f11cbb8d18a0f96d2c24c6d3.tar.gz
unit-64be8717bdc2f0f8f11cbb8d18a0f96d2c24c6d3.tar.bz2
Configuration: added ability to access object members with slashes.
Now URI encoding can be used to escape "/" in the request path: GET /config/listeners/unix:%2Fpath%2Fto%2Fsocket/
Diffstat (limited to 'src/nxt_http_parse.c')
-rw-r--r--src/nxt_http_parse.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/nxt_http_parse.c b/src/nxt_http_parse.c
index 8b4bf47c..945f4e93 100644
--- a/src/nxt_http_parse.c
+++ b/src/nxt_http_parse.c
@@ -1046,12 +1046,25 @@ nxt_http_parse_complex_target(nxt_http_request_parse_t *rp)
if (ch >= '0' && ch <= '9') {
ch = (u_char) ((high << 4) + ch - '0');
- if (ch == '%' || ch == '#') {
+ if (ch == '%') {
state = sw_normal;
- *u++ = ch;
+ *u++ = '%';
+
+ if (rp->encoded_slashes) {
+ *u++ = '2';
+ *u++ = '5';
+ }
+
+ continue;
+ }
+
+ if (ch == '#') {
+ state = sw_normal;
+ *u++ = '#';
continue;
+ }
- } else if (ch == '\0') {
+ if (ch == '\0') {
return NXT_HTTP_PARSE_INVALID;
}
@@ -1067,8 +1080,17 @@ nxt_http_parse_complex_target(nxt_http_request_parse_t *rp)
state = sw_normal;
*u++ = ch;
continue;
+ }
+
+ if (ch == '/' && rp->encoded_slashes) {
+ state = sw_normal;
+ *u++ = '%';
+ *u++ = '2';
+ *u++ = p[-1]; /* 'f' or 'F' */
+ continue;
+ }
- } else if (ch == '+') {
+ if (ch == '+') {
rp->plus_in_target = 1;
}