aboutsummaryrefslogtreecommitdiff
path: root/outboxGet.go
diff options
context:
space:
mode:
authorFChannel <=>2021-01-18 04:41:21 -0800
committerFChannel <=>2021-01-18 04:41:21 -0800
commit8244af05eaa9f66df12095c76309b454bde525d7 (patch)
treeb96a62c2af1597ab77dbaf042c54e43c680b5bc1 /outboxGet.go
parent78ccd8e434d24dccaeec0c1c6fb14f5c991bd567 (diff)
fixed sql injection vulnerabilites.
Diffstat (limited to 'outboxGet.go')
-rw-r--r--outboxGet.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/outboxGet.go b/outboxGet.go
index 1747165..665ca05 100644
--- a/outboxGet.go
+++ b/outboxGet.go
@@ -1,6 +1,5 @@
package main
-import "fmt"
import "net/http"
import "database/sql"
import _ "github.com/lib/pq"
@@ -17,7 +16,7 @@ func GetActorOutbox(w http.ResponseWriter, r *http.Request, db *sql.DB) {
collection.Actor = actor.Id
collection.TotalItems = GetObjectPostsTotalDB(db, actor)
- collection.TotalImgs = GetObjectImgsTotalDB(db, actor)
+ collection.TotalImgs = GetObjectImgsTotalDB(db, actor)
enc, _ := json.MarshalIndent(collection, "", "\t")
w.Header().Set("Content-Type", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"")
@@ -47,9 +46,9 @@ func GetCollectionFromPath(db *sql.DB, path string) Collection {
var nColl Collection
var result []ObjectBase
- query := fmt.Sprintf("SELECT id, name, content, type, published, attributedto, attachment, preview, actor FROM activitystream WHERE id='%s' ORDER BY published desc;", path)
+ query := `select id, name, content, type, published, attributedto, attachment, preview, actor from activitystream where id=$1 order by published desc`
- rows, err := db.Query(query)
+ rows, err := db.Query(query, path)
CheckError(err, "error query collection path from db")
@@ -92,9 +91,9 @@ func GetObjectFromPath(db *sql.DB, path string) ObjectBase{
var nObj ObjectBase
var result []ObjectBase
- query := fmt.Sprintf("SELECT id, name, content, type, published, attributedto, attachment, preview, actor FROM activitystream WHERE id='%s' ORDER BY published desc;", path)
+ query := `select id, name, content, type, published, attributedto, attachment, preview, actor from activitystream where id=$1 order by published desc`
- rows, err := db.Query(query)
+ rows, err := db.Query(query, path)
CheckError(err, "error query collection path from db")