aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--Database.go8
-rw-r--r--config-init (renamed from config)0
-rw-r--r--go.mod3
-rw-r--r--go.sum2
-rw-r--r--main.go17
6 files changed, 25 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index c2128de..5e2780e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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, "<", "&lt;", -1)
diff --git a/config b/config-init
index 2299ea8..2299ea8 100644
--- a/config
+++ b/config-init
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..e5b24f7
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,3 @@
+module github.com/FChannel/Server
+
+require github.com/lib/pq v1.9.0
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..a4a764e
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,2 @@
+github.com/lib/pq v1.9.0 h1:L8nSXQQzAYByakOFMTwpjRoHsMJklur4Gi59b6VivR8=
+github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
diff --git a/main.go b/main.go
index cda1f97..a1f55d8 100644
--- a/main.go
+++ b/main.go
@@ -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
}
+
+