1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-08-13 16:53:50 -04:00

Database: isTitleUsed(): Escape server title (SQLiteException) - Fixes #53

This commit is contained in:
Sebastian Kaspari 2011-04-12 23:30:00 +02:00
parent b3fd4157dc
commit ded6485f6b

View File

@ -31,6 +31,7 @@ import org.yaaic.model.Status;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteOpenHelper;
@ -66,7 +67,7 @@ public class Database extends SQLiteOpenHelper
+ ServerConstants.HOST + " TEXT NOT NULL, " + ServerConstants.HOST + " TEXT NOT NULL, "
+ ServerConstants.PORT + " INTEGER, " + ServerConstants.PORT + " INTEGER, "
+ ServerConstants.PASSWORD + " TEXT, " + ServerConstants.PASSWORD + " TEXT, "
+ ServerConstants.AUTOCONNECT + " BOOLEAN, " // XXX: Does SQLLite support boolean? + ServerConstants.AUTOCONNECT + " BOOLEAN, "
+ ServerConstants.USE_SSL + " BOOLEAN, " + ServerConstants.USE_SSL + " BOOLEAN, "
+ ServerConstants.CHARSET + " TEXT, " + ServerConstants.CHARSET + " TEXT, "
+ ServerConstants.IDENTITY + " INTEGER" + ServerConstants.IDENTITY + " INTEGER"
@ -377,7 +378,7 @@ public class Database extends SQLiteOpenHelper
Cursor cursor = this.getReadableDatabase().query( Cursor cursor = this.getReadableDatabase().query(
ServerConstants.TABLE_NAME, ServerConstants.TABLE_NAME,
ServerConstants.ALL, ServerConstants.ALL,
ServerConstants.TITLE + " = '" + title + "'", ServerConstants.TITLE + " = " + DatabaseUtils.sqlEscapeString(title),
null, null,
null, null,
null, null,
@ -507,6 +508,7 @@ public class Database extends SQLiteOpenHelper
deleteAliases(identityId); deleteAliases(identityId);
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
for (String alias : aliases) { for (String alias : aliases) {
values.clear(); values.clear();
values.put(AliasConstants.ALIAS, alias); values.put(AliasConstants.ALIAS, alias);