Permalink
Browse files

FLTGetBinaryComparisonCommonExpression(): escape date literals with b…

…ackquote (#5104)
  • Loading branch information...
rouault committed Jun 1, 2015
1 parent 29db335 commit ad8589f2da1e23d817fcfbb32d5686860979e675
Showing with 15 additions and 2 deletions.
  1. +15 −2 mapogcfiltercommon.c
@@ -258,6 +258,7 @@ char *FLTGetBinaryComparisonCommonExpression(FilterEncodingNode *psFilterNode, l
char szTmp[1024];
char *pszExpression = NULL, *pszTmpEscaped;
int bString;
int bDateTime;
if (psFilterNode == NULL)
return NULL;
@@ -267,11 +268,15 @@ char *FLTGetBinaryComparisonCommonExpression(FilterEncodingNode *psFilterNode, l
/* is alphanumeric, add quotes around attribute and values. */
/* -------------------------------------------------------------------- */
bString = 0;
bDateTime = 0;
if (psFilterNode->psRightNode->pszValue) {
const char* pszType;
snprintf(szTmp, sizeof(szTmp), "%s_type", psFilterNode->psLeftNode->pszValue);
if (msOWSLookupMetadata(&(lp->metadata), "OFG", szTmp) != NULL &&
(strcasecmp(msOWSLookupMetadata(&(lp->metadata), "OFG", szTmp), "Character") == 0))
pszType = msOWSLookupMetadata(&(lp->metadata), "OFG", szTmp);
if (pszType!= NULL && (strcasecmp(pszType, "Character") == 0))
bString = 1;
else if (pszType!= NULL && (strcasecmp(pszType, "Date") == 0))
bDateTime = 1;
else if (FLTIsNumeric(psFilterNode->psRightNode->pszValue) == MS_FALSE)
bString = 1;
}
@@ -333,6 +338,10 @@ char *FLTGetBinaryComparisonCommonExpression(FilterEncodingNode *psFilterNode, l
sprintf(szTmp, "%s", "\"");
pszExpression = msStringConcatenate(pszExpression, szTmp);
}
else if (bDateTime) {
sprintf(szTmp, "%s", "`");
pszExpression = msStringConcatenate(pszExpression, szTmp);
}
if (psFilterNode->psRightNode->pszValue) {
pszTmpEscaped = msStringEscape(psFilterNode->psRightNode->pszValue);
@@ -344,6 +353,10 @@ char *FLTGetBinaryComparisonCommonExpression(FilterEncodingNode *psFilterNode, l
sprintf(szTmp, "%s", "\"");
pszExpression = msStringConcatenate(pszExpression, szTmp);
}
else if (bDateTime) {
sprintf(szTmp, "%s", "`");
pszExpression = msStringConcatenate(pszExpression, szTmp);
}
sprintf(szTmp, "%s", ")");
pszExpression = msStringConcatenate(pszExpression, szTmp);

0 comments on commit ad8589f

Please sign in to comment.