[master] bbc31a5ea vep: Extract src attr parsing to its own function
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Mon Feb 21 10:23:05 UTC 2022
commit bbc31a5ea9e6a1617eddc7efc4a6d2ca1d01bee9
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Fri Dec 31 15:06:54 2021 +0100
vep: Extract src attr parsing to its own function
diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c
index 0bda28c84..7e0458556 100644
--- a/bin/varnishd/cache/cache_esi_parse.c
+++ b/bin/varnishd/cache/cache_esi_parse.c
@@ -429,6 +429,37 @@ vep_do_remove(struct vep_state *vep, enum dowhat what)
/*---------------------------------------------------------------------
*/
+static void
+include_attr_src(struct vep_state *vep)
+{
+ const char *p;
+
+ if (vep->include_src != NULL) {
+ vep_error(vep,
+ "ESI 1.0 <esi:include> "
+ "has multiple src= attributes");
+ vep->state = VEP_TAGERROR;
+ VSB_destroy(&vep->attr_vsb);
+ VSB_destroy(&vep->include_src);
+ return;
+ }
+ for (p = VSB_data(vep->attr_vsb); *p != '\0'; p++)
+ if (vct_islws(*p))
+ break;
+ if (*p != '\0') {
+ vep_error(vep,
+ "ESI 1.0 <esi:include> "
+ "has whitespace in src= attribute");
+ vep->state = VEP_TAGERROR;
+ VSB_destroy(&vep->attr_vsb);
+ if (vep->include_src != NULL)
+ VSB_destroy(&vep->include_src);
+ return;
+ }
+ vep->include_src = vep->attr_vsb;
+ vep->attr_vsb = NULL;
+}
+
static void v_matchproto_()
vep_do_include(struct vep_state *vep, enum dowhat what)
{
@@ -439,31 +470,11 @@ vep_do_include(struct vep_state *vep, enum dowhat what)
if (what == DO_ATTR) {
Debug("ATTR (%s) (%s)\n", vep->match_hit->match,
VSB_data(vep->attr_vsb));
- if (vep->include_src != NULL) {
- vep_error(vep,
- "ESI 1.0 <esi:include> "
- "has multiple src= attributes");
- vep->state = VEP_TAGERROR;
- VSB_destroy(&vep->attr_vsb);
- VSB_destroy(&vep->include_src);
+ if (!strcmp("src=", vep->match_hit->match)) {
+ include_attr_src(vep);
return;
}
- for (p = VSB_data(vep->attr_vsb); *p != '\0'; p++)
- if (vct_islws(*p))
- break;
- if (*p != '\0') {
- vep_error(vep,
- "ESI 1.0 <esi:include> "
- "has whitespace in src= attribute");
- vep->state = VEP_TAGERROR;
- VSB_destroy(&vep->attr_vsb);
- if (vep->include_src != NULL)
- VSB_destroy(&vep->include_src);
- return;
- }
- vep->include_src = vep->attr_vsb;
- vep->attr_vsb = NULL;
- return;
+ WRONG("Unhandled <esi:include> attribute");
}
assert(what == DO_TAG);
if (!vep->emptytag)
More information about the varnish-commit
mailing list