BUG/MINOR: http-htx: Fix scheme based normalization for URIs wih userinfo
The scheme based normalization is not properly handled the URI's userinfo,
if any. First, the authority parser is not called with "no_userinfo"
parameter set. Then it is skipped from the URI normalization.
This patch must be backported as far as 2.4.
(cherry picked from commit 0eab050b040d4240d78e0c1eb4db937bcddc834f)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit fe951e79d0e04abf0be468faab27b20b40940e57)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit f991a171e72ad06c52e4e7b1bd06e141bf5034d4)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/http_htx.c b/src/http_htx.c
index f0e0a43..6f5c1a1 100644
--- a/src/http_htx.c
+++ b/src/http_htx.c
@@ -1776,7 +1776,7 @@
if (istlen(port) && uri_is_default_port(scheme, port)) {
/* reconstruct the uri with removal of the port */
struct buffer *temp = get_trash_chunk();
- struct ist meth, vsn, path;
+ struct ist meth, vsn;
/* meth */
chunk_memcat(temp, HTX_SL_REQ_MPTR(sl), HTX_SL_REQ_MLEN(sl));
@@ -1787,12 +1787,10 @@
vsn = ist2(temp->area + meth.len, HTX_SL_REQ_VLEN(sl));
/* reconstruct uri without port */
- path = http_get_path(uri);
- chunk_istcat(temp, scheme);
+ chunk_memcat(temp, uri.ptr, authority.ptr - uri.ptr);
chunk_istcat(temp, host);
- chunk_istcat(temp, path);
- uri = ist2(temp->area + meth.len + vsn.len,
- scheme.len + host.len + path.len);
+ chunk_memcat(temp, istend(authority), istend(uri) - istend(authority));
+ uri = ist2(temp->area + meth.len + vsn.len, host.len + uri.len - authority.len); /* uri */
http_replace_stline(htx, meth, uri, vsn);