From: Youngkwang Lee Date: Wed, 9 Sep 2026 08:31:04 +0000 (+0900) Subject: REGTESTS: uri_normalizer: test a normalizer used with a condition X-Git-Tag: v3.5-dev7~31 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=b54c7a8237f3dbfb285916a48b8335727300d5df;p=haproxy.git REGTESTS: uri_normalizer: test a normalizer used with a condition 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. --- 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