Skip to content

Commit ad68998

Browse files
committed
WFS: Make GetFeature with a FEATUREID/RESOURCEID parameter work if the layer name contains a dot (#4925)
1 parent eef2a3d commit ad68998

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

mapwfs.c

+13-11
Original file line numberDiff line numberDiff line change
@@ -2335,8 +2335,8 @@ static int msWFSRetrieveFeatures(mapObj* map,
23352335

23362336

23372337
if (pszFeatureId != NULL) {
2338-
char **tokens = NULL, **tokens1=NULL ;
2339-
int nTokens = 0, j=0, nTokens1=0, k=0;
2338+
char **tokens = NULL;
2339+
int nTokens = 0, j=0, k=0;
23402340
FilterEncodingNode *psNode = NULL;
23412341
char **aFIDLayers = NULL;
23422342
char **aFIDValues = NULL;
@@ -2359,19 +2359,25 @@ static int msWFSRetrieveFeatures(mapObj* map,
23592359
aFIDValues[j] = NULL;
23602360
}
23612361
for (j=0; j<nTokens; j++) {
2362-
tokens1 = msStringSplit(tokens[j], '.', &nTokens1);
2363-
if (tokens1 && nTokens1 == 2) {
2362+
const char* pszLastDot = strrchr(tokens[j], '.');
2363+
if (pszLastDot != NULL) {
2364+
char* pszLayerInFID = msStrdup(tokens[j]);
2365+
pszLayerInFID[pszLastDot - tokens[j]] = '\0';
2366+
/* Find if the layer is already requested */
23642367
for (k=0; k<iFIDLayers; k++) {
2365-
if (strcasecmp(aFIDLayers[k], tokens1[0]) == 0)
2368+
if (strcasecmp(aFIDLayers[k], pszLayerInFID) == 0)
23662369
break;
23672370
}
2371+
/* If not, add it to the list of requested layers */
23682372
if (k == iFIDLayers) {
2369-
aFIDLayers[iFIDLayers] = msStrdup(tokens1[0]);
2373+
aFIDLayers[iFIDLayers] = msStrdup(pszLayerInFID);
23702374
iFIDLayers++;
23712375
}
2376+
/* Add the id to the list of search identifiers of the layer */
23722377
if (aFIDValues[k] != NULL)
23732378
aFIDValues[k] = msStringConcatenate(aFIDValues[k], ",");
2374-
aFIDValues[k] = msStringConcatenate( aFIDValues[k], tokens1[1]);
2379+
aFIDValues[k] = msStringConcatenate( aFIDValues[k], pszLastDot + 1);
2380+
msFree(pszLayerInFID);
23752381
} else {
23762382
/* In WFS 20, an unknown/invalid feature id shouldn't trigger an */
23772383
/* exception. Tested by CITE */
@@ -2381,15 +2387,11 @@ static int msWFSRetrieveFeatures(mapObj* map,
23812387
"msWFSGetFeature()", tokens[j]);
23822388
if (tokens)
23832389
msFreeCharArray(tokens, nTokens);
2384-
if (tokens1)
2385-
msFreeCharArray(tokens1, nTokens1);
23862390
msFreeCharArray(aFIDLayers, iFIDLayers);
23872391
msFreeCharArray(aFIDValues, iFIDLayers);
23882392
return msWFSException(map, "featureid", MS_OWS_ERROR_INVALID_PARAMETER_VALUE, paramsObj->pszVersion);
23892393
}
23902394
}
2391-
if (tokens1)
2392-
msFreeCharArray(tokens1, nTokens1);
23932395
}
23942396
}
23952397
if (tokens)

0 commit comments

Comments
 (0)