Permalink
Browse files

Enclose the sortby property in double quotes by putting the result of…

… msLayerEscapePropertyName into double quotes
  • Loading branch information...
micking committed Jun 29, 2017
1 parent c08e349 commit d5f89a3353854b0f6a8eda0758d99e74372fdf9f
Showing with 13 additions and 3 deletions.
  1. +13 −3 maplayer.c
View
@@ -1604,9 +1604,19 @@ char* msLayerBuildSQLOrderBy(layerObj *layer)
if( layer->sortBy.nProperties > 0 ) {
int i;
for(i=0;i<layer->sortBy.nProperties;i++) {
char* escaped = msSmallMalloc(strlen(layer->sortBy.properties[i].item) + 3);
sprintf(escaped, "\"%s\"", layer->sortBy.properties[i].item);
if( i > 0 )
char* escaped = msLayerEscapePropertyName(layer, layer->sortBy.properties[i].item);
//Enclose property name in double quotes (if it isn't yet) to ensure that mixed case property names are supported
if (escaped[0] != '"')
{
size_t propertyLen = strlen(escaped);
escaped = msSmallRealloc(escaped, propertyLen + 3);
memmove(escaped + 1, escaped, propertyLen);
escaped[0] = '\"';
escaped[propertyLen+1] = '\"';
escaped[propertyLen + 2] = 0;
}
if (i > 0)
strOrderBy = msStringConcatenate(strOrderBy, ", ");
strOrderBy = msStringConcatenate(strOrderBy, escaped);
if( layer->sortBy.properties[i].sortOrder == SORT_DESC )

0 comments on commit d5f89a3

Please sign in to comment.