Fix our problems with strings like this: "abc'def" in template token strings.
authorWilfried Goesgens <dothebart@citadel.org>
Sat, 30 Jul 2011 17:58:48 +0000 (17:58 +0000)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 21:44:55 +0000 (21:44 +0000)
webcit/subst.c

index 54a59a425487e7ec8c45c9a5997dfb5c367fc922..907e1a34f289f3ed9f57239a9daab6da7e005306 100644 (file)
@@ -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;
                        }
                }