MINOR: uri_normalizer: Add `fragment-strip` normalizer
This normalizer strips the URI's fragment component which should never be sent
to the server.
See GitHub Issue #714.
diff --git a/src/http_act.c b/src/http_act.c
index 96ac8f8..f30694e 100644
--- a/src/http_act.c
+++ b/src/http_act.c
@@ -320,6 +320,23 @@
break;
}
+ case ACT_NORMALIZE_URI_FRAGMENT_STRIP: {
+ const struct ist path = http_get_path(uri);
+ struct ist newpath = ist2(replace->area, replace->size);
+
+ if (!isttest(path))
+ goto leave;
+
+ err = uri_normalizer_fragment_strip(path, &newpath);
+
+ if (err != URI_NORMALIZER_ERR_NONE)
+ break;
+
+ if (!http_replace_req_path(htx, newpath, 1))
+ goto fail_rewrite;
+
+ break;
+ }
}
switch (err) {
@@ -440,6 +457,11 @@
return ACT_RET_PRS_ERR;
}
}
+ else if (strcmp(args[cur_arg], "fragment-strip") == 0) {
+ cur_arg++;
+
+ rule->action = ACT_NORMALIZE_URI_FRAGMENT_STRIP;
+ }
else {
memprintf(err, "unknown normalizer '%s'", args[cur_arg]);
return ACT_RET_PRS_ERR;