From fdc78e1b088301681cc4c4b92a04a21981c44cc8 Mon Sep 17 00:00:00 2001 From: Jos Shepherd Date: Fri, 5 Nov 2010 17:03:05 +0000 Subject: [PATCH] Fix for troublesome values being returned from DroidDB stores. Stick to one level of JSON serialization. --- framework/assets/js/storage.js | 3 +-- framework/src/com/phonegap/Storage.java | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/framework/assets/js/storage.js b/framework/assets/js/storage.js index 792dbca4..ca6015f6 100755 --- a/framework/assets/js/storage.js +++ b/framework/assets/js/storage.js @@ -27,9 +27,8 @@ var DroidDB = function() { * @param rawdata JSON string of the row data * @param id Query id */ -DroidDB.prototype.addResult = function(rawdata, id) { +DroidDB.prototype.addResult = function(data, id) { try { - eval("var data = " + rawdata + ";"); var query = this.queryQueue[id]; query.resultSet.push(data); } catch (e) { diff --git a/framework/src/com/phonegap/Storage.java b/framework/src/com/phonegap/Storage.java index 3cf798c5..09266858 100755 --- a/framework/src/com/phonegap/Storage.java +++ b/framework/src/com/phonegap/Storage.java @@ -172,12 +172,12 @@ public class Storage extends Plugin { try { for (int i = 0; i < colCount; ++i) { key = cur.getColumnName(i); - value = cur.getString(i).replace("\"", "\\\""); // must escape " with \" for JavaScript + value = cur.getString(i); result.put(key, value); } - + // Send row back to JavaScript - this.sendJavascript("droiddb.addResult('" + result.toString() + "','" + tx_id + "');"); + this.sendJavascript("droiddb.addResult(" + result.toString() + ",'" + tx_id + "');"); } catch (JSONException e) { e.printStackTrace();