]> err.no Git - varnish/commitdiff
Add esi:comment support. "Support" is defined as: Silently ignore,
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 20 Nov 2007 22:21:05 +0000 (22:21 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 20 Nov 2007 22:21:05 +0000 (22:21 +0000)
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: svn+ssh://projects.linpro.no/svn/varnish/trunk@2282 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_vrt_esi.c

index 5cc87062572a3f4edb3c444959c1350cbec0fe5d..10a8736d4489d5fafa038859180e9f9c3ff0b2b8 100644 (file)
@@ -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");