]> git.kaiwu.me - haproxy.git/commitdiff
REGTESTS: uri_normalizer: test a normalizer used with a condition
authorYoungkwang Lee <ykglory0216@gmail.com>
Wed, 9 Sep 2026 08:31:04 +0000 (17:31 +0900)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 11 Sep 2026 09:37:23 +0000 (11:37 +0200)
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

index 6df9a9890c61b7d56d0bdc2c519b227a6ca5cefb..55790a7522f716b2870cf28577ff5eee5d817c98 100644 (file)
@@ -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