Blame view

string_sanitisation.go 306 Bytes
ea858b8a7   Marko Tikvić   refactoring
1
  package webutility
5f1346d2d   Marko Tikvić   SQLProtect replac...
2

d66628295   Marko Tikvić   cleaned up
3
  import "strings"
5f1346d2d   Marko Tikvić   SQLProtect replac...
4

ea858b8a7   Marko Tikvić   refactoring
5
  var patern string = "\"';&*<>=\\`:"
e1fbb41f9   Marko Tikvić   added comments
6
  // SQLSafeString removes characters from s found in patern and returns new modified string.
b3b60e8b6   Marko Tikvić   string sanitisation
7
  func SanitiseString(s string) (safe string) {
5f1346d2d   Marko Tikvić   SQLProtect replac...
8
  	for _, c := range patern {
e1fbb41f9   Marko Tikvić   added comments
9
  		safe = strings.Replace(s, string(c), "", -1)
5f1346d2d   Marko Tikvić   SQLProtect replac...
10
  	}
e1fbb41f9   Marko Tikvić   added comments
11
  	return safe
5f1346d2d   Marko Tikvić   SQLProtect replac...
12
  }