From: Wilfried Göesgens Date: Thu, 22 Oct 2009 18:21:35 +0000 (+0000) Subject: * new token to put in the actual filename (just works when debugging enabled) X-Git-Tag: v7.86~722 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=57c0db4b938e49d0162be49502ebdd842735c95c * new token to put in the actual filename (just works when debugging enabled) * catch possible access to not set token parameter; off by one. usualy requester should check if the token is there in advance. * check for presence of token in preferences before accessing it --- diff --git a/webcit/preferences.c b/webcit/preferences.c index b8330c9fd..b7a530c5e 100644 --- a/webcit/preferences.c +++ b/webcit/preferences.c @@ -808,9 +808,10 @@ void tmplput_CFG_Descr(StrBuf *Target, WCTemplputParams *TP) void tmplput_CFG_RoomValueLong(StrBuf *Target, WCTemplputParams *TP) { long lvalue; - long defval; + long defval = 0; - defval = GetTemplateTokenNumber(Target, TP, 1, 0); + if (TP->Tokens->nParameters > 1) + defval = GetTemplateTokenNumber(Target, TP, 1, 0); get_ROOM_PREFS_LONG(TKEY(0), &lvalue, defval); StrBufAppendPrintf(Target, "%ld", lvalue); } diff --git a/webcit/subst.c b/webcit/subst.c index 71b8e3ff3..a4a8edea2 100644 --- a/webcit/subst.c +++ b/webcit/subst.c @@ -769,7 +769,7 @@ void GetTemplateTokenString(StrBuf *Target, StrBuf *Buf; WCTemplputParams SubTP; - if (TP->Tokens->nParameters < N) { + if (N >= TP->Tokens->nParameters) { LogTemplateError(Target, "TokenParameter", N, TP, "invalid token %d. this shouldn't have come till here.\n", N); @@ -856,7 +856,7 @@ void GetTemplateTokenString(StrBuf *Target, long GetTemplateTokenNumber(StrBuf *Target, WCTemplputParams *TP, int N, long dflt) { long Ret; - if (TP->Tokens->nParameters < N) { + if (N >= TP->Tokens->nParameters) { LogTemplateError(Target, "TokenParameter", N, TP, "invalid token %d. this shouldn't have come till here.\n", N); @@ -2619,6 +2619,12 @@ int ConditionalLongVector(StrBuf *Target, WCTemplputParams *TP) return 0; } + +void tmplput_CURRENT_FILE(StrBuf *Target, WCTemplputParams *TP) +{ + StrBufAppendTemplate(Target, TP, TP->Tokens->FileName, 0); +} + void InitModule_SUBST (void) @@ -2649,6 +2655,9 @@ InitModule_SUBST RegisterControlNS(HKEY("ITERATE:ODDEVEN"), 0, 0, tmplput_ITERATE_ODDEVEN, CTX_ITERATE); RegisterControlNS(HKEY("ITERATE:KEY"), 0, 0, tmplput_ITERATE_KEY, CTX_ITERATE); RegisterControlNS(HKEY("ITERATE:N"), 0, 0, tmplput_ITERATE_LASTN, CTX_ITERATE); + RegisterNamespace("CURRENTFILE", 0, 1, tmplput_CURRENT_FILE, NULL, CTX_NONE); + + } void