From: phk Date: Tue, 20 Nov 2007 22:21:05 +0000 (+0000) Subject: Add esi:comment support. "Support" is defined as: Silently ignore, X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=73e573fad9e01fdf52a2ef4f81de097cc04f5259;p=varnish 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 which will result in a shmlog record: 11 ESI_xmlerror c at 25: ESI 1.0 unimplemented element "" 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: svn+ssh://projects.linpro.no/svn/varnish/trunk@2282 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_vrt_esi.c b/varnish-cache/bin/varnishd/cache_vrt_esi.c index 5cc87062..10a8736d 100644 --- a/varnish-cache/bin/varnishd/cache_vrt_esi.c +++ b/varnish-cache/bin/varnishd/cache_vrt_esi.c @@ -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