[GRASS-SVN] r69443 - grass/branches/releasebranch_7_0/vector/v.what

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Sep 11 17:49:05 PDT 2016


Author: annakrat
Date: 2016-09-11 17:49:05 -0700 (Sun, 11 Sep 2016)
New Revision: 69443

Modified:
   grass/branches/releasebranch_7_0/vector/v.what/what.c
Log:
v.what: escape backslash in attributes for valid JSON, see #3133 (merge from trunk, r69178)

Modified: grass/branches/releasebranch_7_0/vector/v.what/what.c
===================================================================
--- grass/branches/releasebranch_7_0/vector/v.what/what.c	2016-09-12 00:48:13 UTC (rev 69442)
+++ grass/branches/releasebranch_7_0/vector/v.what/what.c	2016-09-12 00:49:05 UTC (rev 69443)
@@ -22,6 +22,7 @@
     int col, ncols, sqltype, more;
     char buf[5000];
     const char *colname;
+    char *formbuf;
     dbString sql, html, str;
     dbDriver *driver;
     dbHandle handle;
@@ -88,8 +89,10 @@
 
 	    G_debug(2, "%s: %s", colname, db_get_string(&str));
 	    if (json) {
+		formbuf = G_str_replace(db_get_string(&str), "\\", "\\\\");
 		sprintf(buf, "%s\"%s\": \"%s\"", col == 0 ? "" : ",\n",
-			colname, db_get_string(&str));
+			colname, formbuf);
+		G_free(formbuf);
 	    }
 	    else if (script)
 		sprintf(buf, "%s=%s\n", colname, db_get_string(&str));



More information about the grass-commit mailing list