Commit eaa7e28c authored by Tollef Fog Heen's avatar Tollef Fog Heen

Merge r4002: Allow ESI processing on binary data

Fix for bug 476 -- ESI was using null chars to deal with the strings, this made
it impossible to pass binary CDATA through the ESI parser. This switches it to
compare against the end pointer of the string. Test case attached.



git-svn-id: http://www.varnish-cache.org/svn/branches/2.0@4013 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 3a0104f1
......@@ -71,6 +71,7 @@ VTAILQ_HEAD(esibithead, esi_bit);
struct esi_ptr {
const char *p;
const char *e;
struct storage *st;
};
......@@ -108,9 +109,11 @@ Nep(struct esi_ptr *ep)
ep->st = VTAILQ_NEXT(ep->st, list);
if (ep->st != NULL) {
ep->p = (char *)ep->st->ptr;
ep->e = ep->p + ep->st->len;
return;
}
ep->p = finis;
ep->e = finis;
return;
}
......@@ -118,7 +121,7 @@ static void
N(struct esi_work *ew)
{
if (*ew->p.p != '\0')
if (ew->p.p < ew->p.e)
ew->off++;
Nep(&ew->p);
}
......@@ -512,7 +515,7 @@ parse_comment(struct esi_work *ew)
N(ew);
break;
}
} while (*ew->p.p != '\0');
} while (ew->p.p < ew->p.e);
}
/*--------------------------------------------------------------------*/
......@@ -531,7 +534,7 @@ parse_cdata(struct esi_work *ew)
N(ew);
break;
}
} while (*ew->p.p != '\0');
} while (ew->p.p < ew->p.e);
}
/*--------------------------------------------------------------------*/
......@@ -547,8 +550,8 @@ parse_esi_tag(struct esi_work *ew, int closing)
do
N(ew);
while (*ew->p.p != '>' && *ew->p.p != '\0');
if (*ew->p.p == '\0') {
while (*ew->p.p != '>' && ew->p.p < ew->p.e);
if (ew->p.p == ew->p.e) {
esi_addpfx(ew);
esi_error(ew, ew->s.p, 0,
"XML 1.0 incomplete language element");
......@@ -683,11 +686,12 @@ VRT_ESI(struct sess *sp)
ew->p.st = VTAILQ_FIRST(&sp->obj->store);
AN(ew->p.st);
ew->p.p = (char *)ew->p.st->ptr;
ew->p.e = ew->p.p + ew->p.st->len;
/* ->s points to the first un-dealt-with byte */
ew->s = ew->p;
while (*ew->p.p != '\0') {
while (ew->p.p < ew->p.e) {
if (ew->incmt && *ew->p.p == '-' && !CMP(&ew->p, "-->")) {
/* End of ESI comment */
......@@ -724,7 +728,7 @@ VRT_ESI(struct sess *sp)
/* XXX: drop this ? */
do {
N(ew);
} while (*ew->p.p != '>' && *ew->p.p != '\0');
} while (*ew->p.p != '>' && ew->p.p < ew->p.e);
}
}
}
......
# $Id: r00445.vtc 3987 2009-03-23 11:54:19Z sky $
test "zero length ESI include segmens with chunked encoding"
server s1 {
rxreq
expect req.url == "/"
txresp -body {<a><esi:include src="/bar"><b>\0c}
rxreq
expect req.url == "/bar"
txresp
rxreq
expect req.url == "/comment"
txresp -body {<a><!--esi foo --><b>\0c}
rxreq
expect req.url == "/nullbefore"
txresp -body {<a>\0<esi:include src="/bar"><b>c}
} -start
varnish v1 -vcl+backend {
sub vcl_fetch {
esi;
}
} -start
client c1 {
txreq
rxresp
expect resp.bodylen == 8
txreq -url /comment
rxresp
expect resp.bodylen == 13
txreq -url /nullbefore
rxresp
expect resp.bodylen == 8
} -run
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