Commit 84fccfa1 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add esi:comment support. "Support" is defined as: Silently ignore,

as opposed to unhandled esi: elments which we complain about in
varnishlog.

Thus, if you want to get a short comment into the shmlog, the
easiest way is to do something like <esi:say a="Hi Mom"> which will
result in a shmlog record:
   11 ESI_xmlerror c at 25: ESI 1.0 unimplemented element "<esi:say Hi Mom>"
But the length of the message is truncated to avoid dumping the entire
source document into the shmlog.

Snip out any unknown esi: element.

While the ESI 1.0 specification doesn't address this directly, my
impression from the document is that they should never leak through
to the client.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2282 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 7be07e17
......@@ -459,8 +459,6 @@ esi_parse2(struct esi_work *ew)
if (q >= t.e || *q != '>')
return (p);
VSL(SLT_Debug, ew->sp->fd, "Element: [%.*s]", q - p, p);
/* Opening/empty or closing element ? */
if (p[1] == '/') {
celem = 1;
......@@ -474,6 +472,9 @@ VSL(SLT_Debug, ew->sp->fd, "Element: [%.*s]", q - p, p);
r = p + 1;
}
VSL(SLT_Debug, ew->sp->fd, "Element: clos=%d [%.*s]",
celem, q - r, r);
if (r + 9 < q && !memcmp(r, "esi:remove", 10)) {
ew->is_esi++;
......@@ -517,11 +518,26 @@ VSL(SLT_Debug, ew->sp->fd, "Element: [%.*s]", q - p, p);
p = q + 1;
continue;
}
ew->is_esi++;
if (r + 10 < q && !memcmp(r, "esi:comment", 11)) {
ew->o.e = p;
esi_addverbatim(ew);
if (celem == 1) {
esi_error(ew, p, 1 + q - p,
"ESI 1.0 closing esi:comment illegal");
} else if (q[-1] != '/') {
esi_error(ew, p, 1 + q - p,
"ESI 1.0 wants emtpy esi:comment");
}
p = q + 1;
ew->o.b = p;
continue;
}
if (r + 10 < q && !memcmp(r, "esi:include", 11)) {
ew->is_esi++;
ew->o.e = p;
esi_addverbatim(ew);
......@@ -696,6 +712,13 @@ VRT_ESI(struct sess *sp)
/* 'p' is cached starting point for next storage part */
}
/*
* XXX: we could record the starting point of these elements
* XXX: so that the char-index were more useful, but we are
* XXX: not trivially able to print their contents, so leave
* XXX: it like this for now, pending more thought about the
* XXX: proper way to report these errors.
*/
if (ew->incdata)
esi_error(ew, ew->t.e, -1,
"ESI 1.0 unterminated <![CDATA[ element");
......
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