3
0
mirror of https://github.com/apache/cordova-android.git synced 2025-02-28 22:17:50 +08:00

Fix for troublesome values being returned from DroidDB stores. Stick to one level of JSON serialization.

This commit is contained in:
Jos Shepherd 2010-11-05 17:03:05 +00:00
parent 36064c564e
commit fdc78e1b08
2 changed files with 4 additions and 5 deletions
framework
assets/js
src/com/phonegap

View File

@ -27,9 +27,8 @@ var DroidDB = function() {
* @param rawdata JSON string of the row data * @param rawdata JSON string of the row data
* @param id Query id * @param id Query id
*/ */
DroidDB.prototype.addResult = function(rawdata, id) { DroidDB.prototype.addResult = function(data, id) {
try { try {
eval("var data = " + rawdata + ";");
var query = this.queryQueue[id]; var query = this.queryQueue[id];
query.resultSet.push(data); query.resultSet.push(data);
} catch (e) { } catch (e) {

View File

@ -172,12 +172,12 @@ public class Storage extends Plugin {
try { try {
for (int i = 0; i < colCount; ++i) { for (int i = 0; i < colCount; ++i) {
key = cur.getColumnName(i); key = cur.getColumnName(i);
value = cur.getString(i).replace("\"", "\\\""); // must escape " with \" for JavaScript value = cur.getString(i);
result.put(key, value); result.put(key, value);
} }
// Send row back to JavaScript // Send row back to JavaScript
this.sendJavascript("droiddb.addResult('" + result.toString() + "','" + tx_id + "');"); this.sendJavascript("droiddb.addResult(" + result.toString() + ",'" + tx_id + "');");
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();