See RFC 8297 for more information.
http-request normalize-uri <normalizer> [ { if | unless } <condition> ]
-http-request normalize-uri dotdot [ full ] [ { if | unless } <condition> ]
-http-request normalize-uri merge-slashes [ { if | unless } <condition> ]
-http-request normalize-uri percent-upper [ strict ] [ { if | unless } <condition> ]
-http-request normalize-uri sort-query [ { if | unless } <condition> ]
+http-request normalize-uri path-merge-slashes [ { if | unless } <condition> ]
+http-request normalize-uri path-strip-dotdot [ full ] [ { if | unless } <condition> ]
+http-request normalize-uri percent-to-uppercase [ strict ] [ { if | unless } <condition> ]
+http-request normalize-uri query-sort-by-name [ { if | unless } <condition> ]
Performs normalization of the request's URI. The following normalizers are
available:
- - dotdot: Normalizes "/../" segments within the "path" component. This merges
- segments that attempt to access the parent directory with their preceding
- segment. Empty segments do not receive special treatment. Use the
- "merge-slashes" normalizer first if this is undesired.
+ - path-strip-dotdot: Normalizes "/../" segments within the "path" component.
+ This merges segments that attempt to access the parent directory with
+ their preceding segment. Empty segments do not receive special treatment.
+ Use the "path-merge-slashes" normalizer first if this is undesired.
Example:
- /foo/../ -> /
- /../bar/ -> /bar/
- /bar/../../ -> /
- - merge-slashes: Merges adjacent slashes within the "path" component into a
- single slash.
+ - path-merge-slashes: Merges adjacent slashes within the "path" component
+ into a single slash.
Example:
- // -> /
- /foo//bar -> /foo/bar
- - percent-upper: Uppercases letters within percent-encoded sequences
+ - percent-to-uppercase: Uppercases letters within percent-encoded sequences
(RFC 3986#6.2.21).
Example:
Example:
- /%zz -> HTTP 400
- - sort-query: Sorts the query string parameters by parameter name.
+ - query-sort-by-name: Sorts the query string parameters by parameter name.
Parameters are assumed to be delimited by '&'. Shorter names sort before
longer names and identical parameter names maintain their relative order.
};
enum act_normalize_uri {
- ACT_NORMALIZE_URI_MERGE_SLASHES,
- ACT_NORMALIZE_URI_DOTDOT,
- ACT_NORMALIZE_URI_DOTDOT_FULL,
- ACT_NORMALIZE_URI_SORT_QUERY,
- ACT_NORMALIZE_URI_PERCENT_UPPER,
- ACT_NORMALIZE_URI_PERCENT_UPPER_STRICT,
+ ACT_NORMALIZE_URI_PATH_MERGE_SLASHES,
+ ACT_NORMALIZE_URI_PATH_STRIP_DOTDOT,
+ ACT_NORMALIZE_URI_PATH_STRIP_DOTDOT_FULL,
+ ACT_NORMALIZE_URI_QUERY_SORT_BY_NAME,
+ ACT_NORMALIZE_URI_PERCENT_TO_UPPERCASE,
+ ACT_NORMALIZE_URI_PERCENT_TO_UPPERCASE_STRICT,
};
/* NOTE: if <.action_ptr> is defined, the referenced function will always be
timeout client 1s
timeout server 1s
- frontend fe_merge_slashes
- bind "fd@${fe_merge_slashes}"
+ frontend fe_path_merge_slashes
+ bind "fd@${fe_path_merge_slashes}"
http-request set-var(txn.before) url
- http-request normalize-uri merge-slashes
+ http-request normalize-uri path-merge-slashes
http-request set-var(txn.after) url
http-response add-header before %[var(txn.before)]
default_backend be
- frontend fe_dotdot
- bind "fd@${fe_dotdot}"
+ frontend fe_path_strip_dotdot
+ bind "fd@${fe_path_strip_dotdot}"
http-request set-var(txn.before) url
- http-request normalize-uri dotdot
+ http-request normalize-uri path-strip-dotdot
http-request set-var(txn.after) url
http-request set-uri %[var(txn.before)]
- http-request normalize-uri dotdot full
+ http-request normalize-uri path-strip-dotdot full
http-request set-var(txn.after_full) url
http-response add-header before %[var(txn.before)]
default_backend be
- frontend fe_sort_query
- bind "fd@${fe_sort_query}"
+ frontend fe_sort_query_by_name
+ bind "fd@${fe_sort_query_by_name}"
http-request set-var(txn.before) url
- http-request normalize-uri sort-query
+ http-request normalize-uri query-sort-by-name
http-request set-var(txn.after) url
http-response add-header before %[var(txn.before)]
default_backend be
- frontend fe_percent_upper
- bind "fd@${fe_percent_upper}"
+ frontend fe_percent_to_uppercase
+ bind "fd@${fe_percent_to_uppercase}"
http-request set-var(txn.before) url
- http-request normalize-uri percent-upper
+ http-request normalize-uri percent-to-uppercase
http-request set-var(txn.after) url
http-response add-header before %[var(txn.before)]
default_backend be
- frontend fe_percent_upper_strict
- bind "fd@${fe_percent_upper_strict}"
+ frontend fe_percent_to_uppercase_strict
+ bind "fd@${fe_percent_to_uppercase_strict}"
http-request set-var(txn.before) url
- http-request normalize-uri percent-upper strict
+ http-request normalize-uri percent-to-uppercase strict
http-request set-var(txn.after) url
http-response add-header before %[var(txn.before)]
} -start
-client c1 -connect ${h1_fe_merge_slashes_sock} {
+client c1 -connect ${h1_fe_path_merge_slashes_sock} {
txreq -url "/foo/bar"
rxresp
expect resp.http.before == "/foo/bar"
expect resp.http.after == "*"
} -run
-client c2 -connect ${h1_fe_dotdot_sock} {
+client c2 -connect ${h1_fe_path_strip_dotdot_sock} {
txreq -url "/foo/bar"
rxresp
expect resp.http.before == "/foo/bar"
expect resp.http.after-full == "*"
} -run
-client c3 -connect ${h1_fe_sort_query_sock} {
+client c3 -connect ${h1_fe_sort_query_by_name_sock} {
txreq -url "/?a=a"
rxresp
expect resp.http.before == "/?a=a"
expect resp.http.after == "*"
} -run
-client c4 -connect ${h1_fe_percent_upper_sock} {
+client c4 -connect ${h1_fe_percent_to_uppercase_sock} {
txreq -url "/a?a=a"
rxresp
expect resp.http.before == "/a?a=a"
expect resp.http.after == "*"
} -run
-client c5 -connect ${h1_fe_percent_upper_strict_sock} {
+client c5 -connect ${h1_fe_percent_to_uppercase_strict_sock} {
txreq -url "/a?a=a"
rxresp
expect resp.http.before == "/a?a=a"
goto fail_alloc;
switch ((enum act_normalize_uri) rule->action) {
- case ACT_NORMALIZE_URI_MERGE_SLASHES: {
+ case ACT_NORMALIZE_URI_PATH_MERGE_SLASHES: {
const struct ist path = http_get_path(uri);
struct ist newpath = ist2(replace->area, replace->size);
break;
}
- case ACT_NORMALIZE_URI_DOTDOT:
- case ACT_NORMALIZE_URI_DOTDOT_FULL: {
+ case ACT_NORMALIZE_URI_PATH_STRIP_DOTDOT:
+ case ACT_NORMALIZE_URI_PATH_STRIP_DOTDOT_FULL: {
const struct ist path = http_get_path(uri);
struct ist newpath = ist2(replace->area, replace->size);
if (!isttest(path))
goto leave;
- err = uri_normalizer_path_dotdot(iststop(path, '?'), rule->action == ACT_NORMALIZE_URI_DOTDOT_FULL, &newpath);
+ err = uri_normalizer_path_dotdot(iststop(path, '?'), rule->action == ACT_NORMALIZE_URI_PATH_STRIP_DOTDOT_FULL, &newpath);
if (err != URI_NORMALIZER_ERR_NONE)
break;
break;
}
- case ACT_NORMALIZE_URI_SORT_QUERY: {
+ case ACT_NORMALIZE_URI_QUERY_SORT_BY_NAME: {
const struct ist path = http_get_path(uri);
struct ist newquery = ist2(replace->area, replace->size);
break;
}
- case ACT_NORMALIZE_URI_PERCENT_UPPER:
- case ACT_NORMALIZE_URI_PERCENT_UPPER_STRICT: {
+ case ACT_NORMALIZE_URI_PERCENT_TO_UPPERCASE:
+ case ACT_NORMALIZE_URI_PERCENT_TO_UPPERCASE_STRICT: {
const struct ist path = http_get_path(uri);
struct ist newpath = ist2(replace->area, replace->size);
if (!isttest(path))
goto leave;
- err = uri_normalizer_percent_upper(path, rule->action == ACT_NORMALIZE_URI_PERCENT_UPPER_STRICT, &newpath);
+ err = uri_normalizer_percent_upper(path, rule->action == ACT_NORMALIZE_URI_PERCENT_TO_UPPERCASE_STRICT, &newpath);
if (err != URI_NORMALIZER_ERR_NONE)
break;
return ACT_RET_PRS_ERR;
}
- if (strcmp(args[cur_arg], "merge-slashes") == 0) {
+ if (strcmp(args[cur_arg], "path-merge-slashes") == 0) {
cur_arg++;
- rule->action = ACT_NORMALIZE_URI_MERGE_SLASHES;
+ rule->action = ACT_NORMALIZE_URI_PATH_MERGE_SLASHES;
}
- else if (strcmp(args[cur_arg], "dotdot") == 0) {
+ else if (strcmp(args[cur_arg], "path-strip-dotdot") == 0) {
cur_arg++;
if (strcmp(args[cur_arg], "full") == 0) {
cur_arg++;
- rule->action = ACT_NORMALIZE_URI_DOTDOT_FULL;
+ rule->action = ACT_NORMALIZE_URI_PATH_STRIP_DOTDOT_FULL;
}
else if (!*args[cur_arg]) {
- rule->action = ACT_NORMALIZE_URI_DOTDOT;
+ rule->action = ACT_NORMALIZE_URI_PATH_STRIP_DOTDOT;
}
else if (strcmp(args[cur_arg], "if") != 0 && strcmp(args[cur_arg], "unless") != 0) {
memprintf(err, "unknown argument '%s' for 'dotdot' normalizer", args[cur_arg]);
return ACT_RET_PRS_ERR;
}
}
- else if (strcmp(args[cur_arg], "sort-query") == 0) {
+ else if (strcmp(args[cur_arg], "query-sort-by-name") == 0) {
cur_arg++;
- rule->action = ACT_NORMALIZE_URI_SORT_QUERY;
+ rule->action = ACT_NORMALIZE_URI_QUERY_SORT_BY_NAME;
}
- else if (strcmp(args[cur_arg], "percent-upper") == 0) {
+ else if (strcmp(args[cur_arg], "percent-to-uppercase") == 0) {
cur_arg++;
if (strcmp(args[cur_arg], "strict") == 0) {
cur_arg++;
- rule->action = ACT_NORMALIZE_URI_PERCENT_UPPER_STRICT;
+ rule->action = ACT_NORMALIZE_URI_PERCENT_TO_UPPERCASE_STRICT;
}
else if (!*args[cur_arg]) {
- rule->action = ACT_NORMALIZE_URI_PERCENT_UPPER;
+ rule->action = ACT_NORMALIZE_URI_PERCENT_TO_UPPERCASE;
}
else if (strcmp(args[cur_arg], "if") != 0 && strcmp(args[cur_arg], "unless") != 0) {
memprintf(err, "unknown argument '%s' for 'percent-upper' normalizer", args[cur_arg]);