소스 검색

新增防止sql注入

dcsunny 2 년 전
부모
커밋
f670ce153c
1개의 변경된 파일11개의 추가작업 그리고 0개의 파일을 삭제
  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
+}