Amo*_*rni 5 sqlite android sql-injection activeandroid
Android 应用程序已使用 ActiveAndroid 开发
public static List<ModelNames> search(String pattern) {
return new Select().from(ModelNames.class)
.where("title LIKE '%" + pattern + "%' or content LIKE '%" + pattern + "%'")
.orderBy("title")
.execute();
}
Run Code Online (Sandbox Code Playgroud)
现在很容易出现 SQL 注入。
有没有人遇到过类似的问题并找到了解决方案,或者有人可以提供相同的解决方案吗?
在github上发现了一个问题,但无法得到正确的解决方案。
网站上的示例展示了如何使用占位符:
public static List<ModelNames> search(String pattern) {
pattern = "%" + pattern + "%";
return new Select().from(ModelNames.class)
.where("title LIKE ? or content LIKE ?", pattern, pattern)
.orderBy("title")
.execute();
}
Run Code Online (Sandbox Code Playgroud)