MINOR: uri_normalizer: Add support for supressing leading `../` for dotdot normalizer
This adds an option to supress `../` at the start of the resulting path.
diff --git a/src/http_act.c b/src/http_act.c
index 7e1829e..3751b00 100644
--- a/src/http_act.c
+++ b/src/http_act.c
@@ -232,14 +232,15 @@
break;
}
- case ACT_NORMALIZE_URI_DOTDOT: {
+ case ACT_NORMALIZE_URI_DOTDOT:
+ case ACT_NORMALIZE_URI_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, '?'), &newpath);
+ err = uri_normalizer_path_dotdot(iststop(path, '?'), rule->action == ACT_NORMALIZE_URI_DOTDOT_FULL, &newpath);
if (err != URI_NORMALIZER_ERR_NONE)
break;
@@ -317,7 +318,17 @@
else if (strcmp(args[cur_arg], "dotdot") == 0) {
cur_arg++;
- rule->action = ACT_NORMALIZE_URI_DOTDOT;
+ if (strcmp(args[cur_arg], "full") == 0) {
+ cur_arg++;
+ rule->action = ACT_NORMALIZE_URI_DOTDOT_FULL;
+ }
+ else if (!*args[cur_arg]) {
+ rule->action = ACT_NORMALIZE_URI_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 {
memprintf(err, "unknown normalizer '%s'", args[cur_arg]);