]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
Revert "BUG/MINOR: http-rules: Replace path and query-string in "replace-path" action"
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 2 Sep 2020 09:10:38 +0000 (11:10 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 2 Sep 2020 15:29:00 +0000 (17:29 +0200)
This reverts commit 4b9c0d1fc08388bf44c6ebbd88f786032dd010fc.

Actually, the "replace-path" action is ambiguous. "set-path" action preserves
the query-string. The "path" sample fetch does not contain the query-string. But
"replace-path" action is documented to handle the query-string. It is probably
not the expected behavior. So instead of fixing the code, we will fix the
documentation to make "replace-path" action consistent with other parts of the
code. In addition actions and sample fetches to handle the path with the
query-string will be added.

If the commit above is ever backported, this one must be as well.

src/http_act.c
src/http_ana.c

index 51cbf7d7d8b42e723f4521b94977f2309944e959..2eac1254901c73ecdbeb7cb75ee9cdddf1579ff8 100644 (file)
@@ -214,8 +214,8 @@ static enum act_return http_action_replace_uri(struct act_rule *rule, struct pro
                goto fail_alloc;
        uri = htx_sl_req_uri(http_get_stline(htxbuf(&s->req.buf)));
 
-       if (rule->action == 4) // replace-path
-               uri = http_get_path(uri);
+       if (rule->action == 1) // replace-path
+               uri = iststop(http_get_path(uri), '?');
 
        if (!regex_exec_match2(rule->arg.http.re, uri.ptr, uri.len, MAX_MATCH, pmatch, 0))
                goto leave;
@@ -273,7 +273,7 @@ static enum act_parse_ret parse_replace_uri(const char **args, int *orig_arg, st
        char *error = NULL;
 
        if (strcmp(args[cur_arg-1], "replace-path") == 0)
-               rule->action = 4; // replace-path
+               rule->action = 1; // replace-path, same as set-path
        else
                rule->action = 3; // replace-uri, same as set-uri
 
index bce84b9eed18401a8080d3982c2031ad84495057..1334118914f4c78a0854f741c5a6a75baf7fe3a0 100644 (file)
@@ -2785,11 +2785,6 @@ int http_req_replace_stline(int action, const char *replace, int len,
                                return -1;
                        break;
 
-               case 4: // path + query
-                       if (!http_replace_req_path(htx, ist2(replace, len), 1))
-                               return -1;
-                       break;
-
                default:
                        return -1;
        }