Kaynağa Gözat

新增防止sql注入

dcsunny 2 yıl önce
ebeveyn
işleme
f670ce153c
1 değiştirilmiş dosya ile 11 ekleme ve 0 silme
  1. 11 0
      common/sql.go

+ 11 - 0
common/sql.go

@@ -0,0 +1,11 @@
+package common
+
+import "strings"
+
+// SqlStrReplace 防止sql注入
+func SqlStrReplace(str string) string {
+	if strings.Contains(str, "'") {
+		str = strings.Replace(str, "'", "\\'", -1)
+	}
+	return str
+}