mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
✏️ sql 防注入
This commit is contained in:
parent
c824b2e0b4
commit
5645fa0168
@ -13,7 +13,8 @@ func init() {
|
|||||||
Help: "哀伤雪刃推书记录\n- 书评[xxx]\n- 随机书评",
|
Help: "哀伤雪刃推书记录\n- 书评[xxx]\n- 随机书评",
|
||||||
})
|
})
|
||||||
|
|
||||||
engine.OnRegex("^书评(.{1,25})$").SetBlock(true).
|
// 中文、英文、数字但不包括下划线等符号
|
||||||
|
engine.OnRegex("^书评([\u4E00-\u9FA5A-Za-z0-9]{1,25})$").SetBlock(true).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
b := getBookReviewByKeyword(ctx.State["regex_matched"].([]string)[1])
|
b := getBookReviewByKeyword(ctx.State["regex_matched"].([]string)[1])
|
||||||
ctx.SendChain(message.Text(b.BookReview))
|
ctx.SendChain(message.Text(b.BookReview))
|
||||||
|
|||||||
@ -7,7 +7,7 @@ type book struct {
|
|||||||
|
|
||||||
// 暂时随机选择一个书评
|
// 暂时随机选择一个书评
|
||||||
func getBookReviewByKeyword(keyword string) (b book) {
|
func getBookReviewByKeyword(keyword string) (b book) {
|
||||||
db.Find("bookreview", &b, "where bookreview LIKE %"+keyword+"%")
|
db.Find("bookreview", &b, "where bookreview LIKE '%"+keyword+"%'")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user