Permalink
Browse files

Added option to item take to escape strings for JSON output. #4324

  • Loading branch information...
sdlime committed Jul 26, 2016
1 parent fe792cc commit ebb4d7ea0036b2ee23ff8554d049e5b4bcb363cc
Showing with 6 additions and 1 deletion.
  1. +6 −1 maptemplate.c
@@ -1184,7 +1184,7 @@ static int processIncludeTag(mapservObj *mapserv, char **line, FILE *stream, int
/*
** Function to process an [item ...] tag: line contains the tag, shape holds the attributes.
*/
enum ITEM_ESCAPING {ESCAPE_HTML, ESCAPE_URL, ESCAPE_NONE};
enum ITEM_ESCAPING {ESCAPE_HTML, ESCAPE_URL, ESCAPE_JSON, ESCAPE_NONE};

static int processItemTag(layerObj *layer, char **line, shapeObj *shape)
{
@@ -1250,6 +1250,7 @@ static int processItemTag(layerObj *layer, char **line, shapeObj *shape)
argValue = msLookupHashTable(tagArgs, "escape");
if(argValue && strcasecmp(argValue, "url") == 0) escape = ESCAPE_URL;
else if(argValue && strcasecmp(argValue, "none") == 0) escape = ESCAPE_NONE;
else if(argValue && strcasecmp(argValue, "json") == 0) escape = ESCAPE_JSON;

/* TODO: deal with sub strings */
}
@@ -1323,6 +1324,10 @@ static int processItemTag(layerObj *layer, char **line, shapeObj *shape)
encodedTagValue = msEncodeHTMLEntities(tagValue);
*line = msReplaceSubstring(*line, tag, encodedTagValue);
break;
case ESCAPE_JSON:
encodedTagValue = msEscapeJSonString(tagValue);
*line = msReplaceSubstring(*line, tag, encodedTagValue);
break;
case ESCAPE_URL:
encodedTagValue = msEncodeUrl(tagValue);
*line = msReplaceSubstring(*line, tag, encodedTagValue);

0 comments on commit ebb4d7e

Please sign in to comment.