r2282 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Tue Nov 20 23:21:06 CET 2007
Author: phk
Date: 2007-11-20 23:21:05 +0100 (Tue, 20 Nov 2007)
New Revision: 2282
Modified:
trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c
Log:
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.
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-11-20 21:47:37 UTC (rev 2281)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-11-20 22:21:05 UTC (rev 2282)
@@ -459,8 +459,6 @@
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 @@
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 @@
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 @@
/* '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");
More information about the varnish-commit
mailing list