Skip to content

Commit 64c4844

Browse files
committed
fix(io): sql lookup unsafe string (#3930)
Signed-off-by: Jiyong Huang <huangjy@emqx.io>
1 parent 1518ec0 commit 64c4844

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

extensions/impl/sql/lookupSource.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func (g defaultSQLGen) buildQuery(fields []string, keys []string, values []inter
181181
}
182182
switch v := values[i].(type) {
183183
case string:
184-
query += fmt.Sprintf("`%s` = '%s'", k, v)
184+
query += fmt.Sprintf("`%s` = '%s'", k, strings.ReplaceAll(v, "'", "''"))
185185
default:
186186
query += fmt.Sprintf("`%s` = %v", k, v)
187187
}
@@ -210,7 +210,7 @@ func (g noQuoteSQLGen) buildQuery(fields []string, keys []string, values []inter
210210
}
211211
switch v := values[i].(type) {
212212
case string:
213-
query += fmt.Sprintf("%s = '%s'", k, v)
213+
query += fmt.Sprintf("%s = '%s'", k, strings.ReplaceAll(v, "'", "''"))
214214
default:
215215
query += fmt.Sprintf("%s = %v", k, v)
216216
}

0 commit comments

Comments
 (0)