Properly escape query strings, fixed crash
This commit is contained in:
parent
a0ae42dbb9
commit
cb065d0812
@ -6,8 +6,10 @@ package acr.browser.lightning.database;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.DatabaseUtils;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.database.sqlite.SQLiteQuery;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
@ -151,8 +153,10 @@ public class HistoryDatabase extends SQLiteOpenHelper {
|
||||
if (search == null) {
|
||||
return itemList;
|
||||
}
|
||||
String selectQuery = "SELECT * FROM " + TABLE_HISTORY + " WHERE " + KEY_TITLE + " LIKE '%"
|
||||
+ search + "%' OR " + KEY_URL + " LIKE '%" + search + "%' " + "ORDER BY "
|
||||
search = DatabaseUtils.sqlEscapeString('%' + search + '%');
|
||||
|
||||
String selectQuery = "SELECT * FROM " + TABLE_HISTORY + " WHERE " + KEY_TITLE + " LIKE "
|
||||
+ search + " OR " + KEY_URL + " LIKE " + search + " ORDER BY "
|
||||
+ KEY_TIME_VISITED + " DESC LIMIT 5";
|
||||
Cursor cursor = mDatabase.rawQuery(selectQuery, null);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user