--------------------- PatchSet 4709 Date: 2002/08/18 13:25:15 Author: rbcollins Branch: esi Tag: (none) Log: \<\!--esi support Members: src/ESI.c:1.1.2.13->1.1.2.14 Index: squid/src/ESI.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/ESI.c,v retrieving revision 1.1.2.13 retrieving revision 1.1.2.14 diff -u -r1.1.2.13 -r1.1.2.14 --- squid/src/ESI.c 18 Aug 2002 12:35:24 -0000 1.1.2.13 +++ squid/src/ESI.c 18 Aug 2002 13:25:15 -0000 1.1.2.14 @@ -1,6 +1,6 @@ /* - * $Id: ESI.c,v 1.1.2.13 2002/08/18 12:35:24 rbcollins Exp $ + * $Id: ESI.c,v 1.1.2.14 2002/08/18 13:25:15 rbcollins Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -722,6 +722,7 @@ void start(void *data, const XML_Char *el, const char **attr); void end(void *data, const XML_Char *el); void esiExpatDefault (void *data, const XML_Char *s, int len); +void esiExpatComment (void *data, const XML_Char *s); static esiElementType_t esiIdentifyElement (const XML_Char *el) ; @@ -747,13 +748,14 @@ int i; int ellen = strlen (el); char localbuf [HTTP_REQBUF_SZ]; - esiContext *context = data; + XML_Parser parser = data; + esiContext *context = XML_GetUserData(parser); esiElement *element; - int specifiedattcount = XML_GetSpecifiedAttributeCount (context->parserState.p) * 2; + int specifiedattcount = XML_GetSpecifiedAttributeCount (parser) * 2; char *pos; assert (ellen < sizeof (localbuf)); /* prevent unexpected overruns. */ - debug (86, 5)("esiExpatState: element '%s' with %d tags\n", el, specifiedattcount); + debug (86, 5)("esiExpatStart: element '%s' with %d tags\n", el, specifiedattcount); if (context->flags.error) /* waiting for expat to finish the buffer we gave it */ @@ -840,7 +842,8 @@ int ellen = strlen (el); char localbuf [HTTP_REQBUF_SZ]; char *pos; - esiContext *context = data; + XML_Parser parser = data; + esiContext *context = XML_GetUserData(parser); if (context->flags.error) /* waiting for expat to finish the buffer we gave it */ @@ -849,7 +852,8 @@ switch (esiIdentifyElement (el)) { case ESI_ELEMENT_NONE: assert (ellen < sizeof (localbuf)); /* prevent unexpected overruns. */ - /* Add elements we aren't interested in */ localbuf[0] = '<'; + /* Add elements we aren't interested in */ + localbuf[0] = '<'; localbuf[1] = '/'; assert (xstrncpy (&localbuf[2], el, sizeof(localbuf) - 3)); pos = localbuf + strlen (localbuf); @@ -870,12 +874,62 @@ void esiExpatDefault (void *data, const XML_Char *s, int len) { - esiContext *context = data; + XML_Parser parser = data; + esiContext *context = XML_GetUserData(parser); /* handle and skipped data */ if (esiAddLiteral (context, s, len)) context->flags.error = 1; } +void +esiExpatComment (void *data, const XML_Char *s) +{ + XML_Parser parser = data; + esiContext *context = XML_GetUserData(parser); + if (!strncmp(s, "esi",3)) { + XML_Parser p; + debug (86,1)("esiExpatComment: ESI ", 4); + if (esiAddLiteral (context, localbuf,len + 7)) + context->flags.error = 1; + } +} + int esiAddLiteral (esiContext *context, const XML_Char *s, int len) { @@ -919,6 +973,8 @@ XML_SetUserData (context->parserState.p, context); XML_SetElementHandler(context->parserState.p, start, end); XML_SetDefaultHandler(context->parserState.p, esiExpatDefault); + XML_SetCommentHandler(context->parserState.p, esiExpatComment); + XML_UseParserAsHandlerArg(context->parserState.p); } /* we have data */ @@ -1497,8 +1553,15 @@ } } rv->context = cbdataReference(context); - esiIncludeStart (rv->src, rv->srcurl); - esiIncludeStart (rv->alt, rv->alturl); + if (rv->src) { + esiIncludeStart (rv->src, rv->srcurl); + esiIncludeStart (rv->alt, rv->alturl); + } else { + if (rv->alt) + cbdataFree (rv->alt); + debug (86,1)("esiIncludeNew: esi:include with no src attributes\n"); + rv->flags.failed = 1; + } return (esiElement *)rv; }