/* * Copyright (C) 1996-2018 The Squid Software Foundation and contributors * * Squid software is distributed under GPLv2+ license and includes * contributions from numerous individuals and organizations. * Please see the COPYING and CONTRIBUTORS files for details. */ /* DEBUG: section 86 ESI processing */ #include "squid.h" #include "Debug.h" #include "esi/CustomParser.h" #include "fatal.h" #include "libTrie/Trie.h" #include "libTrie/TrieCharTransform.h" #include Trie *ESICustomParser::SearchTrie=NULL; EsiParserDefinition(ESICustomParser); Trie * ESICustomParser::GetTrie() { if (SearchTrie) return SearchTrie; SearchTrie = new Trie(new TrieCaseless); static const ESITAG_t ESITAG_value = ESITAG; assert (SearchTrie->add ("add ("add (""); if (!commentEnd) { error = "missing end of comment"; return false; } if (commentEnd - tag > (ssize_t)remainingCount) { error = "comment ends beyond parse buffer"; return false; } *commentEnd = '\0'; theClient->parserComment (tag + 4); remainingCount -= commentEnd - currentPos + 3; currentPos = commentEnd + 3; } break; break; default: fatal ("unknown ESI tag type found"); }; /* * Find next esi tag (open or closing) or comment * send tag, or full comment text * rinse */ } if (remainingCount) theClient->parserDefault (currentPos,remainingCount); debugs(86, 5, "ESICustomParser::parse: Finished parsing, will return " << !openESITags); if (openESITags) error = "ESI Tags still open"; return !openESITags; } long int ESICustomParser::lineNumber() const { /* We don't track lines in the body */ return 0; } char const * ESICustomParser::errorString() const { if (error.size()) return error.termedBuf(); else return "Parsing error strings not implemented"; }