Commit 880b4ba3 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Pål Hermunn Johansen

Change assert to proper error message and test it.

Fixes #2197
parent 59952224
......@@ -489,7 +489,14 @@ vep_do_include(struct vep_state *vep, enum dowhat what)
if (l > 7 && !memcmp(p, "http://", 7)) {
h = p + 7;
p = strchr(h, '/');
AN(p);
if (p == NULL) {
vep_error(vep,
"ESI 1.0 <esi:include> invalid src= URL");
vep->state = VEP_TAGERROR;
AZ(vep->attr_vsb);
VSB_destroy(&vep->include_src);
return;
}
Debug("HOST <%.*s> PATH <%s>\n", (int)(p-h),h, p);
VSB_printf(vep->vsb, "%c", VEC_INCL);
VSB_printf(vep->vsb, "Host: %.*s%c", (int)(p-h), h, 0);
......@@ -506,7 +513,14 @@ vep_do_include(struct vep_state *vep, enum dowhat what)
"ESI 1.0 <esi:include> https:// treated as http://");
h = p + 8;
p = strchr(h, '/');
AN(p);
if (p == NULL) {
vep_error(vep,
"ESI 1.0 <esi:include> invalid src= URL");
vep->state = VEP_TAGERROR;
AZ(vep->attr_vsb);
VSB_destroy(&vep->include_src);
return;
}
VSB_printf(vep->vsb, "%c", VEC_INCL);
VSB_printf(vep->vsb, "Host: %.*s%c", (int)(p-h), h, 0);
} else if (*p == '/') {
......
......@@ -43,3 +43,49 @@ client c1 {
client c1 -run
varnish v1 -expect esi_errors == 0
# Now try with invalid URLs
server s1 {
rxreq
expect req.url == /http
txresp -body {<esi:include src="http://foobar" />1234}
rxreq
expect req.url == /https
txresp -body {<esi:include src="https://foobar" />123456}
} -start
varnish v1 -vcl+backend {
sub vcl_recv {
set req.backend_hint = s2;
set req.backend_hint = s1;
}
sub vcl_backend_response {
set beresp.do_esi = true;
}
}
varnish v1 -cliok "param.set feature +esi_ignore_https"
logexpect l1 -v v1 -g raw {
expect * * ESI_xmlerror "ERR at 35 ESI 1.0 <esi:include> invalid src= URL"
expect * * ESI_xmlerror "WARN at 36 ESI 1.0 <esi:include> https:// treated as http://"
expect * * ESI_xmlerror "ERR at 36 ESI 1.0 <esi:include> invalid src= URL"
} -start
client c1 {
txreq -url /http
rxresp
expect resp.status == 200
expect resp.bodylen == 4
txreq -url /https
rxresp
expect resp.status == 200
expect resp.bodylen == 6
}
client c1 -run
logexpect l1 -wait
varnish v1 -expect esi_errors == 2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment