mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-09 08:37:04 +02:00
BUG/MINOR: http-rules: Replace path and query-string in "replace-path" action
The documentation stated the "replace-path" action replaces the path, including
the query-string if any is present. But in the code, only the path is
replaced. The query-string is preserved. So, now, instead of relying on the same
action code than "set-uri" action (1), a new action code (4) is used for
"replace-path" action. In http_req_replace_stline() function, when the action
code is 4, we call http_replace_req_path() setting the last argument (with_qs)
to 1. This way, the query-string is not skipped but included to the path to be
replaced.
This patch relies on the commit b8ce505c6
("MINOR: http-htx: Add an option to
eval query-string when the path is replaced"). Both must be backported as far as
2.0. It should fix the issue #829.
This commit is contained in:
parent
b8ce505c6f
commit
4b9c0d1fc0
@ -214,8 +214,8 @@ static enum act_return http_action_replace_uri(struct act_rule *rule, struct pro
|
|||||||
goto fail_alloc;
|
goto fail_alloc;
|
||||||
uri = htx_sl_req_uri(http_get_stline(htxbuf(&s->req.buf)));
|
uri = htx_sl_req_uri(http_get_stline(htxbuf(&s->req.buf)));
|
||||||
|
|
||||||
if (rule->action == 1) // replace-path
|
if (rule->action == 4) // replace-path
|
||||||
uri = iststop(http_get_path(uri), '?');
|
uri = http_get_path(uri);
|
||||||
|
|
||||||
if (!regex_exec_match2(rule->arg.http.re, uri.ptr, uri.len, MAX_MATCH, pmatch, 0))
|
if (!regex_exec_match2(rule->arg.http.re, uri.ptr, uri.len, MAX_MATCH, pmatch, 0))
|
||||||
goto leave;
|
goto leave;
|
||||||
@ -273,7 +273,7 @@ static enum act_parse_ret parse_replace_uri(const char **args, int *orig_arg, st
|
|||||||
char *error = NULL;
|
char *error = NULL;
|
||||||
|
|
||||||
if (strcmp(args[cur_arg-1], "replace-path") == 0)
|
if (strcmp(args[cur_arg-1], "replace-path") == 0)
|
||||||
rule->action = 1; // replace-path, same as set-path
|
rule->action = 4; // replace-path
|
||||||
else
|
else
|
||||||
rule->action = 3; // replace-uri, same as set-uri
|
rule->action = 3; // replace-uri, same as set-uri
|
||||||
|
|
||||||
|
@ -2785,6 +2785,11 @@ int http_req_replace_stline(int action, const char *replace, int len,
|
|||||||
return -1;
|
return -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 4: // path + query
|
||||||
|
if (!http_replace_req_path(htx, ist2(replace, len), 1))
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user