Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sql injection when updating fts #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.houxg.leamonax.database;


import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.raizlabs.android.dbflow.config.FlowManager;
import com.raizlabs.android.dbflow.sql.language.Join;
Expand Down Expand Up @@ -40,8 +42,10 @@ public static List<Note> searchByTitle(String keyword) {
public static void updateFTSNoteByLocalId(Long localId) {
Note note = getByLocalId(localId);
DatabaseWrapper databaseWrapper = FlowManager.getWritableDatabase(AppDataBase.class);
String query = "UPDATE fts_note SET content = '" + note.getContent() + "' where rowid = " + localId;
databaseWrapper.execSQL(query);
ContentValues args = new ContentValues();
args.put("content", note.getContent());
// String query = "UPDATE fts_note SET content = '" + note.getContent() + "' where rowid = " + localId;
databaseWrapper.updateWithOnConflict("fts_note", args, "rowid = " + localId, null, SQLiteDatabase.CONFLICT_REPLACE);
}

public static boolean isExistsTableFTSNote() {
Expand Down