diff options
author | FChannel <=> | 2021-01-17 12:06:01 -0800 |
---|---|---|
committer | FChannel <=> | 2021-01-17 12:06:01 -0800 |
commit | a4c64444b2b3df780a7a23e65d24f03dc983a188 (patch) | |
tree | acdd5cddf3899ab6a5a8e3e1616fb82c6aea89c3 | |
parent | 08cfcaf5d4062adc37079430b83c741a1f355ae9 (diff) |
added go mod and config-init
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Database.go | 8 | ||||
-rw-r--r-- | config-init (renamed from config) | 0 | ||||
-rw-r--r-- | go.mod | 3 | ||||
-rw-r--r-- | go.sum | 2 | ||||
-rw-r--r-- | main.go | 17 |
6 files changed, 25 insertions, 8 deletions
@@ -1,5 +1,4 @@ *~ #* public/ -backupconfig0 -backupconfig1 +config
\ No newline at end of file diff --git a/Database.go b/Database.go index f033a5b..00c6025 100644 --- a/Database.go +++ b/Database.go @@ -228,7 +228,7 @@ func writeActivitytoDB(db *sql.DB, obj ObjectBase) { obj.Content = EscapeString(obj.Content) obj.AttributedTo = EscapeString(obj.AttributedTo) - query := fmt.Sprintf("insert into activitystream (id, type, name, content, published, updated, attributedto, actor) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", obj.Id ,obj.Type, obj.Name, obj.Content, obj.Published, obj.Updated, obj.AttributedTo, obj.Actor.Id) + query := fmt.Sprintf("insert into activitystream (id, type, name, content, published, updated, attributedto, actor) values ('%s', '%s', E'%s', E'%s', '%s', '%s', E'%s', '%s')", obj.Id ,obj.Type, obj.Name, obj.Content, obj.Published, obj.Updated, obj.AttributedTo, obj.Actor.Id) _, e := db.Exec(query) @@ -244,7 +244,7 @@ func writeActivitytoDBWithAttachment(db *sql.DB, obj ObjectBase, attachment Obje obj.Content = EscapeString(obj.Content) obj.AttributedTo = EscapeString(obj.AttributedTo) - query := fmt.Sprintf("insert into activitystream (id, type, name, content, attachment, published, updated, attributedto, actor) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", obj.Id ,obj.Type, obj.Name, obj.Content, attachment.Id, obj.Published, obj.Updated, obj.AttributedTo, obj.Actor.Id) + query := fmt.Sprintf("insert into activitystream (id, type, name, content, attachment, published, updated, attributedto, actor) values ('%s', '%s', E'%s', E'%s', '%s', '%s', '%s', E'%s', '%s')", obj.Id ,obj.Type, obj.Name, obj.Content, attachment.Id, obj.Published, obj.Updated, obj.AttributedTo, obj.Actor.Id) _, e := db.Exec(query) @@ -823,9 +823,9 @@ func DeleteCaptchaCodeDB(db *sql.DB, verify string) { } func EscapeString(text string) string { - re := regexp.MustCompile("(?i)(n)(\\s+)?(i)(\\s+)?(g)(\\s+)?(g)?(\\s+)?(e)(\\s+)?(r)(\\s+)?") + re := regexp.MustCompile("(?i)(n)+(\\s+)?(i)+(\\s+)?(g)+(\\s+)?(e)+?(\\s+)?(r)+(\\s+)?") text = re.ReplaceAllString(text, "I love black people") - re = regexp.MustCompile("(?i)(n)(\\s+)?(i)(\\s+)?(g)(\\s+)?(g)(\\s+)?") + re = regexp.MustCompile("(?i)(n)+(\\s+)?(i)+(\\s+)?(g)(\\s+)?(g)+(\\s+)?") text = re.ReplaceAllString(text, "I love black people") text = strings.Replace(text, "'", "''", -1) text = strings.Replace(text, "<", "<", -1) @@ -0,0 +1,3 @@ +module github.com/FChannel/Server + +require github.com/lib/pq v1.9.0 @@ -0,0 +1,2 @@ +github.com/lib/pq v1.9.0 h1:L8nSXQQzAYByakOFMTwpjRoHsMJklur4Gi59b6VivR8= +github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= @@ -24,7 +24,7 @@ var Domain = TP + "" + GetConfigValue("instance") var authReq = []string{"captcha","email","passphrase"} -var supportedFiles = []string{"image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/avif","image/apng","video/mp4","video/ogg","video/webm","audio/mpeg","audio/ogg","audio/wav"} +var supportedFiles = []string{"image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/avif","image/apng","video/mp4","video/ogg","video/webm","audio/mpeg","audio/ogg","audio/wav", "audio/wave", "audio/x-wav"} var SiteEmail string //contact@fchan.xyz var SiteEmailPassword string @@ -389,6 +389,17 @@ func CreateTripCode(input string) string { return out.String() } +func CreateNameTripCode(input string) string { + fmt.Println("AHHHHHHHHHH") + re := regexp.MustCompile("#.+") + chunck := re.FindString(input) + fmt.Println(input) + fmt.Println(chunck) + hash := CreateTripCode(chunck) + fmt.Println(hash[0:8]) + return re.ReplaceAllString(input, hash[0:8]) +} + func GetActorFromPath(db *sql.DB, location string, prefix string) Actor { pattern := fmt.Sprintf("%s([^/\n]+)(/.+)?", prefix) re := regexp.MustCompile(pattern) @@ -426,7 +437,7 @@ func GetContentType(location string) string { func RandomID(size int) string { rand.Seed(time.Now().UnixNano()) - domain := "0123456789ABCDEF" + domain := "0123456789ABCDEFG" rng := size newID := "" for i := 0; i < rng; i++ { @@ -1009,3 +1020,5 @@ func IsInStringArray(array []string, value string) bool { } return false } + + |