aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Database.go6
-rw-r--r--OutboxPost.go28
-rw-r--r--main.go13
3 files changed, 33 insertions, 14 deletions
diff --git a/Database.go b/Database.go
index 6c3f711..f033a5b 100644
--- a/Database.go
+++ b/Database.go
@@ -6,6 +6,7 @@ import _ "github.com/lib/pq"
import "time"
import "os"
import "strings"
+import "regexp"
func GetActorFromDB(db *sql.DB, id string) Actor {
@@ -822,8 +823,11 @@ 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+)?")
+ text = re.ReplaceAllString(text, "I love black people")
+ 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)
text = strings.Replace(text, "<", "&lt;", -1)
return text
}
diff --git a/OutboxPost.go b/OutboxPost.go
index 772014a..90c30d7 100644
--- a/OutboxPost.go
+++ b/OutboxPost.go
@@ -25,9 +25,9 @@ func ParseOutboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) {
if(BoardHasAuthType(db, actor.Name, "captcha") && CheckCaptcha(db, r.FormValue("captcha"))) {
f, header, _ := r.FormFile("file")
if(header != nil) {
- if(header.Size > (5 << 20)){
+ if(header.Size > (7 << 20)){
w.WriteHeader(http.StatusRequestEntityTooLarge)
- w.Write([]byte("5MB max file size"))
+ w.Write([]byte("7MB max file size"))
return
}
@@ -43,7 +43,7 @@ func ParseOutboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) {
var nObj = CreateObject("Note")
nObj = ObjectFromForm(r, db, nObj)
-
+
var act Actor
nObj.Actor = &act
nObj.Actor.Id = Domain + "/" + actor.Name
@@ -83,9 +83,6 @@ func ParseOutboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) {
w.WriteHeader(http.StatusOK)
w.Write([]byte(id))
}
-
-
-
} else {
activity = GetActivityFromJson(r, db)
if IsActivityLocal(db, activity) {
@@ -356,14 +353,19 @@ func ObjectFromForm(r *http.Request, db *sql.DB, obj ObjectBase) ObjectBase {
obj.InReplyTo = append(obj.InReplyTo, originalPost)
var activity Activity
-
- activity.To = append(activity.To, originalPost.Id)
+
+ if !IsInStringArray(activity.To, originalPost.Id) {
+ activity.To = append(activity.To, originalPost.Id)
+ }
+
if originalPost.Id != "" {
if !IsActivityLocal(db, activity) {
id := GetActorFromID(originalPost.Id).Id
-
- obj.To = append(obj.To, GetActor(id).Id)
+ actor := GetActor(id)
+ if !IsInStringArray(obj.To, actor.Id) {
+ obj.To = append(obj.To, actor.Id)
+ }
}
}
@@ -389,8 +391,10 @@ func ObjectFromForm(r *http.Request, db *sql.DB, obj ObjectBase) ObjectBase {
if !IsActivityLocal(db, activity) {
id := GetActorFromID(e.Id).Id
-
- obj.To = append(obj.To, GetActor(id).Id)
+ actor := GetActor(id)
+ if !IsInStringArray(obj.To, actor.Id) {
+ obj.To = append(obj.To, actor.Id)
+ }
}
}
}
diff --git a/main.go b/main.go
index 3e67f36..cda1f97 100644
--- a/main.go
+++ b/main.go
@@ -583,7 +583,9 @@ func ParseCommentForReplies(comment string) []ObjectBase {
str = strings.Replace(str, "http://", "", 1)
str = strings.Replace(str, "https://", "", 1)
str = TP + "" + str
- links = append(links, str)
+ if !IsInStringArray(links, str) {
+ links = append(links, str)
+ }
}
var validLinks []ObjectBase
@@ -998,3 +1000,12 @@ func PrintAdminAuth(db *sql.DB){
fmt.Println("Admin Login: " + identifier + ", Code: " + code)
}
+
+func IsInStringArray(array []string, value string) bool {
+ for _, e := range array {
+ if e == value {
+ return true
+ }
+ }
+ return false
+}