Permalink
Browse files

FLTGetBinaryComparisonCommonExpression(): escape date literals with b…

…ackquote (#5104)
  • Loading branch information...
rouault committed Jun 1, 2015
1 parent 7593b85 commit b7a7339363483c009096992f1e64668561e7a124
Showing with 15 additions and 1 deletion.
  1. +15 −1 mapogcfiltercommon.c
View
@@ -244,6 +244,7 @@ char *FLTGetBinaryComparisonCommonExpression(FilterEncodingNode *psFilterNode, l
char szTmp[1024];
char *pszExpression = NULL, *pszTmpEscaped;
int bString;
+ int bDateTime;
if (psFilterNode == NULL)
return NULL;
@@ -253,10 +254,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;
}
@@ -306,6 +312,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);
@@ -317,6 +327,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 b7a7339

Please sign in to comment.