[master] cf658eb5f vcc: Ensure the authority does not contain a :<port>
Nils Goroll
nils.goroll at uplex.de
Fri Feb 7 11:04:09 UTC 2025
commit cf658eb5f181c736a04de9d8ef421a563a9024ec
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Fri Feb 7 10:32:35 2025 +0100
vcc: Ensure the authority does not contain a :<port>
First part of #3963
diff --git a/bin/varnishtest/tests/c00042.vtc b/bin/varnishtest/tests/c00042.vtc
index ed69de824..dc3c5dc12 100644
--- a/bin/varnishtest/tests/c00042.vtc
+++ b/bin/varnishtest/tests/c00042.vtc
@@ -110,7 +110,7 @@ varnish v1 -vcl {
.via = v2;
.host = "${s1_addr}";
.port = "${s1_port}";
- .host_header = "host.com";
+ .host_header = "host.com:1234";
}
sub vcl_recv {
diff --git a/doc/sphinx/reference/vcl-backend.rst b/doc/sphinx/reference/vcl-backend.rst
index 00904acbf..5d3ddd372 100644
--- a/doc/sphinx/reference/vcl-backend.rst
+++ b/doc/sphinx/reference/vcl-backend.rst
@@ -219,6 +219,8 @@ The HTTP authority to use when connecting to this backend. If unset,
``.authority = ""`` disables sending an authority.
+A colon and anything following (signifying a port) is removed from the authority.
+
As of this release, the attribute is only used by ``.via`` connections
as a ``PP2_TYPE_AUTHORITY`` Type-Length-Value (TLV) in the `PROXY2`_
preamble.
diff --git a/lib/libvcc/vcc_backend.c b/lib/libvcc/vcc_backend.c
index 7e6bf64c6..31332b4a1 100644
--- a/lib/libvcc/vcc_backend.c
+++ b/lib/libvcc/vcc_backend.c
@@ -374,8 +374,9 @@ vcc_ParseHostDef(struct vcc *tl, struct symbol *sym,
vtim_dur first_byte_timeout = NAN;
vtim_dur between_bytes_timeout = NAN;
vtim_dur backend_wait_timeout = NAN;
- char *p;
+ char *p, *pp;
unsigned u;
+ int l;
if (tl->t->tok == ID &&
(vcc_IdIs(tl->t, "none") || vcc_IdIs(tl->t, "None"))) {
@@ -675,8 +676,11 @@ vcc_ParseHostDef(struct vcc *tl, struct symbol *sym,
t_val = t_host;
p = t_val->dec;
+ pp = strchr(p, ':');
+ l = (pp == NULL) ? -1 : (int)(pp - p);
+
Fb(tl, 0, "\t.authority = ");
- VSB_quote(tl->fb, p, -1, VSB_QUOTE_CSTR);
+ VSB_quote(tl->fb, p, l, VSB_QUOTE_CSTR);
Fb(tl, 0, ",\n");
}
More information about the varnish-commit
mailing list