The existing tests always use the normalizers unconditionally, so the
selection of the normalizer when a condition directly follows a
normalizer whose sub-option is omitted was not covered.
The request uses both a percent sequence and duplicate slashes so that
the expected result differs depending on which normalizer is picked:
percent-decode-unreserved leaves the duplicate slashes alone, while
path-merge-slashes, which was wrongly selected before the previous
commit, would merge them and leave the percent sequence encoded.
---
reg-tests/http-rules/normalize_uri.vtc | 27 ++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/reg-tests/http-rules/normalize_uri.vtc
b/reg-tests/http-rules/normalize_uri.vtc
index 6df9a9890..55790a752 100644
--- a/reg-tests/http-rules/normalize_uri.vtc
+++ b/reg-tests/http-rules/normalize_uri.vtc
@@ -159,6 +159,23 @@ haproxy h1 -conf {
http-request normalize-uri fragment-strip
default_backend be
+ # A normalizer with an optional sub-option that is followed by a
+ # condition instead of the sub-option must still select the right
+ # normalizer and not fall back to the first one of the enum.
+ frontend fe_cond
+ bind "fd@${fe_cond}"
+
+ acl always_match always_true
+
+ http-request set-var(txn.before) url
+ http-request normalize-uri percent-decode-unreserved if always_match
+ http-request set-var(txn.after) url
+
+ http-response add-header before %[var(txn.before)]
+ http-response add-header after %[var(txn.after)]
+
+ default_backend be
+
backend be
server s1 ${s1_addr}:${s1_port}
@@ -550,3 +567,13 @@ client c11 -connect ${h1_fe_fragment_block_sock} {
rxresp
expect resp.status == 400
} -run
+
+client c12 -connect ${h1_fe_cond_sock} {
+ # the percent sequence must be decoded and the duplicate slashes must
+ # be left alone, which would not be the case if path-merge-slashes was
+ # selected instead.
+ txreq -url "/a//b/%62"
+ rxresp
+ expect resp.http.before == "/a//b/%62"
+ expect resp.http.after == "/a//b/b"
+} -run
--
2.45.1