[master] 2a5345de1 vsl: Facilitate ESI_xmlerror processing

Nils Goroll nils.goroll at uplex.de
Tue Aug 12 09:21:06 UTC 2025


commit 2a5345de14efee39838f87c57908fe10d02decc2
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Wed Aug 6 12:36:24 2025 +0200

    vsl: Facilitate ESI_xmlerror processing
    
    varnishncsa supports the %{VSL:tag:record-prefix[field]}x format variable to
    output records which "have this prefix as the first part of the record content
    followed by a colon".
    
    It would be convenient to be able to use this variable also for ESI_xmlerror as
    
            %{VSL:ESI_xmlerror:WARN}x
            %{VSL:ESI_xmlerror:ERR}x"
    
    yet the prefix was missing a colon.
    
    This patch adds it, plus it also adds a WARN: prefix to "No ESI processing"
    messages.
    
    Most of the diff was produced using
    
            sed -i '/ESI_xmlerror/ s:\(ERR\|WARN\):\0\::' $(git grep -l ESI_xml)

diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c
index 5145b016c..0b183a35d 100644
--- a/bin/varnishd/cache/cache_esi_parse.c
+++ b/bin/varnishd/cache/cache_esi_parse.c
@@ -201,7 +201,7 @@ static void
 vep_error(const struct vep_state *vep, const char *p)
 {
 	VSC_C_main->esi_errors++;
-	VSLb(vep->vc->wrk->vsl, SLT_ESI_xmlerror, "ERR after %zd %s",
+	VSLb(vep->vc->wrk->vsl, SLT_ESI_xmlerror, "ERR: after %zd %s",
 	     vep->o_last, p);
 }
 
@@ -213,7 +213,7 @@ static void
 vep_warn(const struct vep_state *vep, const char *p)
 {
 	VSC_C_main->esi_warnings++;
-	VSLb(vep->vc->wrk->vsl, SLT_ESI_xmlerror, "WARN after %zd %s",
+	VSLb(vep->vc->wrk->vsl, SLT_ESI_xmlerror, "WARN: after %zd %s",
 	     vep->o_last, p);
 }
 
@@ -673,14 +673,14 @@ VEP_Parse(struct vep_state *vep, const char *p, size_t l)
 				vep->state = VEP_STARTTAG;
 			} else if (p < e && *p == (char)0xeb) {
 				VSLb(vep->vc->wrk->vsl, SLT_ESI_xmlerror,
-				    "No ESI processing, "
+				    "WARN: No ESI processing, "
 				    "first char not '<' but BOM."
 				    " (See feature esi_remove_bom)"
 				);
 				vep->state = VEP_NOTXML;
 			} else if (p < e) {
 				VSLb(vep->vc->wrk->vsl, SLT_ESI_xmlerror,
-				    "No ESI processing, "
+				    "WARN: No ESI processing, "
 				    "first char not '<'."
 				    " (See feature esi_disable_xml_check)"
 				);
diff --git a/bin/varnishtest/tests/e00001.vtc b/bin/varnishtest/tests/e00001.vtc
index c903a0acb..9e4cf5286 100644
--- a/bin/varnishtest/tests/e00001.vtc
+++ b/bin/varnishtest/tests/e00001.vtc
@@ -23,8 +23,8 @@ varnish v1 -vcl+backend {
 } -start
 
 logexpect l1 -v v1 -g raw {
-	expect * * ESI_xmlerror {^ERR after 3 ESI 1.0 <esi:include> element nested in <esi:remove>}
-	expect 0 = ESI_xmlerror {^ERR after 3 ESI 1.0 Nested <!--esi element in <esi:remove>}
+	expect * * ESI_xmlerror {^ERR: after 3 ESI 1.0 <esi:include> element nested in <esi:remove>}
+	expect 0 = ESI_xmlerror {^ERR: after 3 ESI 1.0 Nested <!--esi element in <esi:remove>}
 } -start
 
 client c1 {
diff --git a/bin/varnishtest/tests/e00006.vtc b/bin/varnishtest/tests/e00006.vtc
index b6b511808..82cf5c9f3 100644
--- a/bin/varnishtest/tests/e00006.vtc
+++ b/bin/varnishtest/tests/e00006.vtc
@@ -69,9 +69,9 @@ varnish v1 -vcl+backend {
 varnish v1 -cliok "param.set feature +esi_ignore_https"
 
 logexpect l1 -v v1 -g raw {
-	expect * * ESI_xmlerror "ERR after 0 ESI 1.0 <esi:include> invalid src= URL"
-	expect * * ESI_xmlerror "WARN after 0 ESI 1.0 <esi:include> https:// treated as http://"
-	expect * * ESI_xmlerror "ERR after 0 ESI 1.0 <esi:include> invalid src= URL"
+	expect * * ESI_xmlerror "^ERR: after 0 ESI 1.0 <esi:include> invalid src= URL"
+	expect * * ESI_xmlerror "^WARN: after 0 ESI 1.0 <esi:include> https:// treated as http://"
+	expect * * ESI_xmlerror "^ERR: after 0 ESI 1.0 <esi:include> invalid src= URL"
 } -start
 
 client c1 {
diff --git a/bin/varnishtest/tests/e00008.vtc b/bin/varnishtest/tests/e00008.vtc
index 1264aea55..775e45f18 100644
--- a/bin/varnishtest/tests/e00008.vtc
+++ b/bin/varnishtest/tests/e00008.vtc
@@ -67,34 +67,34 @@ varnish v1 -vcl+backend {
 
 logexpect l1 -v v1 -g vxid {
 	expect * * BereqURL	{^/$}
-	expect * * ESI_xmlerror {^ERR after 134 ESI 1.0 <esi:bogus> element$}
-	expect 0 = ESI_xmlerror {^ERR after 157 ESI 1.0 <esi:comment> needs final '/'$}
-	expect 0 = ESI_xmlerror {^ERR after 192 ESI 1.0 </esi:comment> illegal end-tag$}
-	expect 0 = ESI_xmlerror {^ERR after 251 ESI 1.0 <esi:comment> element nested in <esi:remove>$}
-	expect 0 = ESI_xmlerror {^ERR after 330 ESI 1.0 <esi:remove> already open$}
-	expect 0 = ESI_xmlerror {^ERR after 407 ESI 1.0 <esi:remove> not open$}
-	expect 0 = ESI_xmlerror {^ERR after 442 ESI 1.0 <esi:remove/> not legal$}
-	expect 0 = ESI_xmlerror {^ERR after 474 XML 1.0 Illegal attribute start char$}
-	expect 0 = ESI_xmlerror {^ERR after 525 ESI 1.0 <esi:include> lacks src attr$}
-	expect 0 = ESI_xmlerror {^ERR after 553 XML 1.0 Illegal attr char$}
-	expect 0 = ESI_xmlerror {^ERR after 581 ESI 1.0 <esi:include> lacks src attr$}
-	expect 0 = ESI_xmlerror {^ERR after 608 XML 1.0 Missing end attribute delimiter$}
-	expect 0 = ESI_xmlerror {^ERR after 636 XML 1.0 Illegal attribute delimiter$}
-	expect 0 = ESI_xmlerror {^ERR after 665 ESI 1.0 </esi:include> illegal end-tag$}
-	expect 0 = ESI_xmlerror {^ERR after 767 XML 1.0 Missing end attribute delimiter$}
-	expect 0 = ESI_xmlerror {^ERR after 843 ESI 1.0 <esi:include> has whitespace in src= attribute$}
+	expect * * ESI_xmlerror {^ERR: after 134 ESI 1.0 <esi:bogus> element$}
+	expect 0 = ESI_xmlerror {^ERR: after 157 ESI 1.0 <esi:comment> needs final '/'$}
+	expect 0 = ESI_xmlerror {^ERR: after 192 ESI 1.0 </esi:comment> illegal end-tag$}
+	expect 0 = ESI_xmlerror {^ERR: after 251 ESI 1.0 <esi:comment> element nested in <esi:remove>$}
+	expect 0 = ESI_xmlerror {^ERR: after 330 ESI 1.0 <esi:remove> already open$}
+	expect 0 = ESI_xmlerror {^ERR: after 407 ESI 1.0 <esi:remove> not open$}
+	expect 0 = ESI_xmlerror {^ERR: after 442 ESI 1.0 <esi:remove/> not legal$}
+	expect 0 = ESI_xmlerror {^ERR: after 474 XML 1.0 Illegal attribute start char$}
+	expect 0 = ESI_xmlerror {^ERR: after 525 ESI 1.0 <esi:include> lacks src attr$}
+	expect 0 = ESI_xmlerror {^ERR: after 553 XML 1.0 Illegal attr char$}
+	expect 0 = ESI_xmlerror {^ERR: after 581 ESI 1.0 <esi:include> lacks src attr$}
+	expect 0 = ESI_xmlerror {^ERR: after 608 XML 1.0 Missing end attribute delimiter$}
+	expect 0 = ESI_xmlerror {^ERR: after 636 XML 1.0 Illegal attribute delimiter$}
+	expect 0 = ESI_xmlerror {^ERR: after 665 ESI 1.0 </esi:include> illegal end-tag$}
+	expect 0 = ESI_xmlerror {^ERR: after 767 XML 1.0 Missing end attribute delimiter$}
+	expect 0 = ESI_xmlerror {^ERR: after 843 ESI 1.0 <esi:include> has whitespace in src= attribute$}
 	expect 0 = BackendClose
 } -start
 
 logexpect l2 -v v1 -g vxid {
 	expect * * BereqURL	{^/body$}
-	expect * = ESI_xmlerror {^ERR after 30 VEP ended inside a tag$}
+	expect * = ESI_xmlerror {^ERR: after 30 VEP ended inside a tag$}
 	expect 0 = BackendClose
 } -start
 
 logexpect l3 -v v1 -g vxid {
 	expect * * BereqURL	{^/body2$}
-	expect * = ESI_xmlerror {^ERR after 39 VEP ended inside a tag$}
+	expect * = ESI_xmlerror {^ERR: after 39 VEP ended inside a tag$}
 	expect 0 = BackendClose
 } -start
 
diff --git a/bin/varnishtest/tests/e00019.vtc b/bin/varnishtest/tests/e00019.vtc
index b0b08b8df..1fb159ec0 100644
--- a/bin/varnishtest/tests/e00019.vtc
+++ b/bin/varnishtest/tests/e00019.vtc
@@ -57,12 +57,12 @@ varnish v1 -cliok "param.set debug +syncvsl"
 
 logexpect l1 -v v1 -g vxid -q "vxid == 1002" {
 	expect * * Fetch_Body
-	expect 0 = ESI_xmlerror {^ERR after 3 ESI 1.0 </esi:comment> illegal end-tag$}
-	expect 0 = ESI_xmlerror {^ERR after 27 XML 1.0 '>' does not follow '/' in tag$}
-	expect 0 = ESI_xmlerror {^ERR after 43 ESI 1.0 <esi:comment> needs final '/'$}
-	expect 0 = ESI_xmlerror {^WARN after 107 ESI 1.0 <esi:include> lacks final '/'$}
-	expect 0 = ESI_xmlerror {^ERR after 130 ESI 1.0 <esi:bogus> element$}
-	expect 0 = ESI_xmlerror {^ERR after 131837 VEP ended inside a tag$}
+	expect 0 = ESI_xmlerror {^ERR: after 3 ESI 1.0 </esi:comment> illegal end-tag$}
+	expect 0 = ESI_xmlerror {^ERR: after 27 XML 1.0 '>' does not follow '/' in tag$}
+	expect 0 = ESI_xmlerror {^ERR: after 43 ESI 1.0 <esi:comment> needs final '/'$}
+	expect 0 = ESI_xmlerror {^WARN: after 107 ESI 1.0 <esi:include> lacks final '/'$}
+	expect 0 = ESI_xmlerror {^ERR: after 130 ESI 1.0 <esi:bogus> element$}
+	expect 0 = ESI_xmlerror {^ERR: after 131837 VEP ended inside a tag$}
 	expect 0 = BackendClose
 } -start
 
diff --git a/bin/varnishtest/tests/e00020.vtc b/bin/varnishtest/tests/e00020.vtc
index 75210778f..45f8be539 100644
--- a/bin/varnishtest/tests/e00020.vtc
+++ b/bin/varnishtest/tests/e00020.vtc
@@ -24,8 +24,8 @@ varnish v1 -cliok "param.set http_gzip_support true"
 
 logexpect l1 -v v1 -g vxid {
 	expect * * Fetch_Body
-	expect 0 = ESI_xmlerror {^ERR after 3 ESI 1.0 <esi:include> element nested in <esi:remove>$}
-	expect 0 = ESI_xmlerror {^ERR after 3 ESI 1.0 Nested <!--esi element in <esi:remove>$}
+	expect 0 = ESI_xmlerror {^ERR: after 3 ESI 1.0 <esi:include> element nested in <esi:remove>$}
+	expect 0 = ESI_xmlerror {^ERR: after 3 ESI 1.0 Nested <!--esi element in <esi:remove>$}
 	expect 0 = Gzip         {^U}
 	expect 0 = BackendClose
 } -start
diff --git a/bin/varnishtest/tests/e00022.vtc b/bin/varnishtest/tests/e00022.vtc
index 2a99c8acd..e2caab769 100644
--- a/bin/varnishtest/tests/e00022.vtc
+++ b/bin/varnishtest/tests/e00022.vtc
@@ -29,8 +29,8 @@ varnish v1 -cliok "param.set gzip_memlevel 1"
 
 logexpect l1 -v v1 -g vxid {
 	expect * * Fetch_Body
-	expect 0 = ESI_xmlerror {^ERR after 24 ESI 1.0 <esi:include> element nested in <esi:remove>$}
-	expect 0 = ESI_xmlerror {^ERR after 24 ESI 1.0 Nested <!--esi element in <esi:remove>$}
+	expect 0 = ESI_xmlerror {^ERR: after 24 ESI 1.0 <esi:include> element nested in <esi:remove>$}
+	expect 0 = ESI_xmlerror {^ERR: after 24 ESI 1.0 Nested <!--esi element in <esi:remove>$}
 	expect 0 = Gzip         {^G}
 	expect 0 = Gzip         {^U}
 	expect 0 = BackendClose
diff --git a/bin/varnishtest/tests/r00894.vtc b/bin/varnishtest/tests/r00894.vtc
index 0cb094822..2f2aa9d2a 100644
--- a/bin/varnishtest/tests/r00894.vtc
+++ b/bin/varnishtest/tests/r00894.vtc
@@ -13,7 +13,7 @@ varnish v1 -vcl+backend {
 
 logexpect l1 -v v1 -g raw {
 	expect * * Fetch_Body
-	expect 0 = ESI_xmlerror {^ERR after 5 ESI 1.0 <esi:include> has multiple src= attributes$}
+	expect 0 = ESI_xmlerror {^ERR: after 5 ESI 1.0 <esi:include> has multiple src= attributes$}
 	expect 0 = BackendClose
 } -start
 
diff --git a/bin/varnishtest/tests/r01092.vtc b/bin/varnishtest/tests/r01092.vtc
index 468f6a591..1312d1c10 100644
--- a/bin/varnishtest/tests/r01092.vtc
+++ b/bin/varnishtest/tests/r01092.vtc
@@ -26,7 +26,7 @@ varnish v1 -vcl+backend {
 
 logexpect l1 -v v1 -g raw {
 	expect * * Fetch_Body
-	expect 0 * ESI_xmlerror {^ERR after 66 ESI 1.0 Nested <!--esi element in <esi:remove>$}
+	expect 0 * ESI_xmlerror {^ERR: after 66 ESI 1.0 Nested <!--esi element in <esi:remove>$}
 	expect 0 = BackendClose
 } -start
 
diff --git a/bin/varnishtest/tests/r01355.vtc b/bin/varnishtest/tests/r01355.vtc
index 5385b2a31..e20036116 100644
--- a/bin/varnishtest/tests/r01355.vtc
+++ b/bin/varnishtest/tests/r01355.vtc
@@ -23,11 +23,11 @@ varnish v1 -vcl+backend {
 
 logexpect l1 -v v1 -g raw {
 	expect * * Fetch_Body
-	expect 0 = ESI_xmlerror {^No ESI processing, first char not '<' but BOM. .See feature esi_remove_bom.$}
+	expect 0 = ESI_xmlerror {^WARN: No ESI processing, first char not '<' but BOM. .See feature esi_remove_bom.$}
 	expect 0 = BackendClose
 # XXX another logexpect weirdness - why can't we catch the second occurrence?
 #	expect * * Fetch_Body
-#	expect 0 = ESI_xmlerror {^No ESI processing, first char not '<' but BOM. .See feature esi_remove_bom.$}
+#	expect 0 = ESI_xmlerror {^WARN: No ESI processing, first char not '<' but BOM. .See feature esi_remove_bom.$}
 #	expect 0 = BackendClose
 } -start
 


More information about the varnish-commit mailing list