X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fsubst.c;h=fd72242b2f7c37cfce01b6d399b13bc70326666f;hb=972cd0d4d4784a16ba6c30ed1348266ca452cbfa;hp=586f4f8c646df6b156107b9b25451c2892fed9e0;hpb=7ad28ef5f9698f8bc237937ea25e77739d5b208f;p=citadel.git diff --git a/webcit/subst.c b/webcit/subst.c index 586f4f8c6..fd72242b2 100644 --- a/webcit/subst.c +++ b/webcit/subst.c @@ -679,6 +679,7 @@ void StrBufAppendTemplate(StrBuf *Target, char EscapeAs = ' '; if ((FormatTypeIndex < TP->Tokens->nParameters) && + (TP->Tokens->Params[FormatTypeIndex] != NULL) && (TP->Tokens->Params[FormatTypeIndex]->Type == TYPE_STR) && (TP->Tokens->Params[FormatTypeIndex]->len >= 1)) { pFmt = TP->Tokens->Params[FormatTypeIndex]->Start; @@ -1983,6 +1984,7 @@ typedef struct _HashIterator { RetrieveHashlistFunc GetHash; HashDestructorFunc Destructor; SubTemplFunc DoSubTemplate; + FilterByParamFunc Filter; } HashIterator; void RegisterITERATOR(const char *Name, long len, @@ -1991,6 +1993,7 @@ void RegisterITERATOR(const char *Name, long len, RetrieveHashlistFunc GetHash, SubTemplFunc DoSubTempl, HashDestructorFunc Destructor, + FilterByParamFunc Filter, CtxType ContextType, CtxType XPectContextType, int Flags) @@ -2004,6 +2007,7 @@ void RegisterITERATOR(const char *Name, long len, It->GetHash = GetHash; It->DoSubTemplate = DoSubTempl; It->Destructor = Destructor; + It->Filter = Filter; It->ContextType = ContextType; It->XPectContextType = XPectContextType; It->Flags = Flags; @@ -2157,6 +2161,13 @@ void tmpl_iterate_subtmpl(StrBuf *Target, WCTemplputParams *TP) } while (GetNextHashPos(List, it, &Status.KeyLen, &Status.Key, &vContext)) { if ((Status.n >= StartAt) && (Status.n <= StopAt)) { + + if ((It->Filter != NULL) && + !It->Filter(Status.Key, Status.KeyLen, vContext, Target, TP)) + { + continue; + } + if (DetectGroupChange && Status.n > 0) { Status.GroupChange = SortBy->GroupChange(vContext, vLastContext); }