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.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;
|
||||||
|
import android.database.sqlite.SQLiteQuery;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
@ -151,8 +153,10 @@ public class HistoryDatabase extends SQLiteOpenHelper {
|
|||||||
if (search == null) {
|
if (search == null) {
|
||||||
return itemList;
|
return itemList;
|
||||||
}
|
}
|
||||||
String selectQuery = "SELECT * FROM " + TABLE_HISTORY + " WHERE " + KEY_TITLE + " LIKE '%"
|
search = DatabaseUtils.sqlEscapeString('%' + search + '%');
|
||||||
+ search + "%' OR " + KEY_URL + " LIKE '%" + search + "%' " + "ORDER BY "
|
|
||||||
|
String selectQuery = "SELECT * FROM " + TABLE_HISTORY + " WHERE " + KEY_TITLE + " LIKE "
|
||||||
|
+ search + " OR " + KEY_URL + " LIKE " + search + " ORDER BY "
|
||||||
+ KEY_TIME_VISITED + " DESC LIMIT 5";
|
+ KEY_TIME_VISITED + " DESC LIMIT 5";
|
||||||
Cursor cursor = mDatabase.rawQuery(selectQuery, null);
|
Cursor cursor = mDatabase.rawQuery(selectQuery, null);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user