[mapserver-commits] r10650 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Sat Oct 23 14:41:12 EDT 2010


Author: assefa
Date: 2010-10-23 11:41:12 -0700 (Sat, 23 Oct 2010)
New Revision: 10650

Modified:
   trunk/mapserver/mapwfs.c
Log:
Return an error if the number of filters is incorrect (#3584)

Modified: trunk/mapserver/mapwfs.c
===================================================================
--- trunk/mapserver/mapwfs.c	2010-10-23 16:52:06 UTC (rev 10649)
+++ trunk/mapserver/mapwfs.c	2010-10-23 18:41:12 UTC (rev 10650)
@@ -2132,27 +2132,32 @@
       /*      20,20</gml:coordinates></gml:Box></Within></Filter>)            */
       /* -------------------------------------------------------------------- */
       nFilters = 0;
-      if (strlen(pszFilter) > 0 && pszFilter[0] == '(') {
-	tokens = msStringSplit(pszFilter+1, '(', &nFilters);
+      if (strlen(pszFilter) > 0 && pszFilter[0] == '(') 
+      {
+          tokens = msStringSplit(pszFilter+1, '(', &nFilters);
 	
-	if (tokens == NULL || nFilters <=0 || nFilters != numlayers) {
-	  msSetError(MS_WFSERR, "Wrong number of FILTER attributes",
-		     "msWFSGetFeature()");
-	  return msWFSException(map, "filter", "InvalidParameterValue", paramsObj->pszVersion);
-	}
-         
-	paszFilter = (char **)malloc(sizeof(char *)*nFilters);
-	for (i=0; i<nFilters; i++)
-	  paszFilter[i] = strdup(tokens[i]);
+          if (tokens &&  nFilters > 0 && numlayers == nFilters)
+          {
+              paszFilter = (char **)malloc(sizeof(char *)*nFilters);
+              for (i=0; i<nFilters; i++)
+                paszFilter[i] = strdup(tokens[i]);
 	
-	if (tokens)
-	  msFreeCharArray(tokens, nFilters);
-      } else {
-	nFilters=1;
-	paszFilter = (char **)malloc(sizeof(char *)*nFilters);
-	paszFilter[0] = pszFilter;
+              msFreeCharArray(tokens, nFilters);
+          }
+      } 
+      else if (numlayers == 1)
+      {
+          nFilters=1;
+          paszFilter = (char **)malloc(sizeof(char *)*nFilters);
+          paszFilter[0] = pszFilter;
       }
-        
+      
+      if (numlayers != nFilters)
+      {
+          msSetError(MS_WFSERR, "Wrong number of filter elements, one filter must be specified for each feature type listed in the TYPENAME parameter.",
+                     "msWFSGetFeature()");
+          return msWFSException(map, "filter", "InvalidParameterValue", paramsObj->pszVersion);
+      }
       /* -------------------------------------------------------------------- */
       /*      run through the filters and build the class expressions.        */
       /*      TODO: items may have namespace prefixes, or reference aliases,  */



More information about the mapserver-commits mailing list