MINOR: uri_normalizer: Add a `percent-upper` normalizer
This normalizer uppercases the hexadecimal characters used in percent-encoding.
See GitHub Issue #714.
diff --git a/src/http_act.c b/src/http_act.c
index 1480563..06ecb9e 100644
--- a/src/http_act.c
+++ b/src/http_act.c
@@ -267,6 +267,24 @@
break;
}
+ case ACT_NORMALIZE_URI_PERCENT_UPPER:
+ case ACT_NORMALIZE_URI_PERCENT_UPPER_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);
+
+ if (err != URI_NORMALIZER_ERR_NONE)
+ break;
+
+ if (!http_replace_req_path(htx, newpath, 1))
+ goto fail_rewrite;
+
+ break;
+ }
}
switch (err) {
@@ -352,6 +370,21 @@
rule->action = ACT_NORMALIZE_URI_SORT_QUERY;
}
+ else if (strcmp(args[cur_arg], "percent-upper") == 0) {
+ cur_arg++;
+
+ if (strcmp(args[cur_arg], "strict") == 0) {
+ cur_arg++;
+ rule->action = ACT_NORMALIZE_URI_PERCENT_UPPER_STRICT;
+ }
+ else if (!*args[cur_arg]) {
+ rule->action = ACT_NORMALIZE_URI_PERCENT_UPPER;
+ }
+ 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]);
+ return ACT_RET_PRS_ERR;
+ }
+ }
else {
memprintf(err, "unknown normalizer '%s'", args[cur_arg]);
return ACT_RET_PRS_ERR;