[mapserver-commits] r7690 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Wed Jun 18 09:56:15 EDT 2008


Author: Assefa
Date: 2008-06-18 09:56:15 -0400 (Wed, 18 Jun 2008)
New Revision: 7690

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/maputil.c
Log:
Correct expression evaluation with text containing apostrophes (#2641)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2008-06-18 13:35:26 UTC (rev 7689)
+++ trunk/mapserver/HISTORY.TXT	2008-06-18 13:56:15 UTC (rev 7690)
@@ -13,8 +13,10 @@
 Current Version (SVN trunk):
 ----------------------------
 
--  mapwfs.c: Genrate possibly an error message when applying filter encoding (#2444)
+- maputil.c: Correct expression evaluation with text containing apostrophes (#2641)
 
+- mapwfs.c: Genrate possibly an error message when applying filter encoding (#2444)
+
 - Added MS_LABEL_BINDING constants for SWIG MapScript (#2643)
 
 - mapogcsos.c: fix POST support (#2379)

Modified: trunk/mapserver/maputil.c
===================================================================
--- trunk/mapserver/maputil.c	2008-06-18 13:35:26 UTC (rev 7689)
+++ trunk/mapserver/maputil.c	2008-06-18 13:56:15 UTC (rev 7690)
@@ -333,7 +333,7 @@
 int msEvalExpression(expressionObj *expression, int itemindex, char **items, int numitems)
 {
   int i;
-  char *tmpstr=NULL;
+  char *tmpstr=NULL, *tmpstr2=NULL;
   int status;
   int expresult;  /* result of logical expression parsing operation */
   
@@ -359,9 +359,10 @@
     tmpstr = strdup(expression->string);
 
     for(i=0; i<expression->numitems; i++) {
-        items[expression->indexes[i]] = msReplaceSubstring( items[expression->indexes[i]], "\'", "\\\'");
-        items[expression->indexes[i]] = msReplaceSubstring( items[expression->indexes[i]], "\"", "\\\"");
-        tmpstr = msReplaceSubstring(tmpstr, expression->items[i], items[expression->indexes[i]]);
+      tmpstr2 = strdup(items[expression->indexes[i]]);
+      tmpstr2 = msReplaceSubstring(tmpstr2, "\'", "\\\'");
+      tmpstr2 = msReplaceSubstring(tmpstr2, "\"", "\\\"");
+      tmpstr = msReplaceSubstring(tmpstr, expression->items[i], tmpstr2);
     }
     msAcquireLock( TLOCK_PARSER );
     msyystate = MS_TOKENIZE_EXPRESSION;
@@ -374,9 +375,14 @@
     {
         msSetError(MS_PARSEERR, "Failed to parse expression: %s", "msEvalExpression", tmpstr);
         free(tmpstr);
+        if(tmpstr2)
+          free(tmpstr2);
+            
         return MS_FALSE;
     }
     free(tmpstr);
+    if(tmpstr2)
+      free(tmpstr2);
     return expresult;
     
     break;



More information about the mapserver-commits mailing list