From 74fb658b25f766426a43cb1a6d55a699bb05dbc5 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sat, 30 Jul 2011 17:58:48 +0000 Subject: [PATCH] Fix our problems with strings like this: "abc'def" in template token strings. --- webcit/subst.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/webcit/subst.c b/webcit/subst.c index 54a59a425..907e1a34f 100644 --- a/webcit/subst.c +++ b/webcit/subst.c @@ -1233,8 +1233,7 @@ void *load_template(WCTemplate *NewTemplate) pE = pS + StrLength(NewTemplate->Data); while (pch < pE) { const char *pts, *pte; - int InQuotes = 0; - int InDoubleQuotes = 0; + char InQuotes = '\0'; void *pv; /** Find one */ @@ -1253,13 +1252,24 @@ void *load_template(WCTemplate *NewTemplate) /** Found one? parse it. */ for (; pch <= pE - 1; pch ++) { - if (*pch == '"') - InDoubleQuotes = ! InDoubleQuotes; - else if (*pch == '\'') - InQuotes = ! InQuotes; - else if ((!InQuotes && !InDoubleQuotes) && - ((*pch!='\\')&&(*(pch + 1)=='>'))) { - pch ++; + if ((!InQuotes) && + ((*pch == '\'') || (*pch == '"'))) + { + InQuotes = *pch; + } + else if (InQuotes && (InQuotes == *pch)) + { + InQuotes = '\0'; + } + else if ((InQuotes) && + (*pch == '\\') && + (*(pch + 1) == InQuotes)) + { + pch++; + } + else if ((!InQuotes) && + (*pch == '>')) + { break; } } -- 2.30.2