Parcourir la source

新增防止sql注入

dcsunny il y a 2 ans
Parent
commit
f670ce153c
1 fichiers modifiés avec 11 ajouts et 0 suppressions
  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
+}