ReplaceSQL.go 755 B

123456789101112131415161718192021222324
  1. package lib
  2. import "strings"
  3. // 过滤sql特殊字符
  4. func ReplaceSQL(name string) string {
  5. name = strings.Replace(name, ";", "", -1)
  6. name = strings.Replace(name, ",", "", -1)
  7. name = strings.Replace(name, "?", "", -1)
  8. name = strings.Replace(name, "<", "", -1)
  9. name = strings.Replace(name, ">", "", -1)
  10. name = strings.Replace(name, "(", "", -1)
  11. name = strings.Replace(name, ")", "", -1)
  12. name = strings.Replace(name, "@", "", -1)
  13. name = strings.Replace(name, "=", "", -1)
  14. name = strings.Replace(name, "+", "", -1)
  15. name = strings.Replace(name, "*", "", -1)
  16. name = strings.Replace(name, "&", "", -1)
  17. name = strings.Replace(name, "#", "", -1)
  18. name = strings.Replace(name, "%", "", -1)
  19. name = strings.Replace(name, "$", "", -1)
  20. return name
  21. }