Skip to content

Commit

Permalink
fix nil deref when posting without authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkr committed Dec 14, 2024
1 parent 1d4cd3d commit 2cd60e6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
10 changes: 10 additions & 0 deletions front/dm.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ import (
)

func (h *Handler) dm(w text.Writer, r *Request, args ...string) {
if r.User == nil {
w.Redirect("/users")
return
}

to := ap.Audience{}
cc := ap.Audience{}

Expand All @@ -31,6 +36,11 @@ func (h *Handler) dm(w text.Writer, r *Request, args ...string) {
}

func (h *Handler) uploadDM(w text.Writer, r *Request, args ...string) {
if r.User == nil {
w.Redirect("/users")
return
}

to := ap.Audience{}
cc := ap.Audience{}

Expand Down
5 changes: 0 additions & 5 deletions front/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ var (
)

func (h *Handler) post(w text.Writer, r *Request, oldNote *ap.Object, inReplyTo *ap.Object, to ap.Audience, cc ap.Audience, audience string, readInput inputFunc) {
if r.User == nil {
w.Redirect("/users")
return
}

now := ap.Time{Time: time.Now()}

if oldNote == nil {
Expand Down
5 changes: 5 additions & 0 deletions front/reply.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ import (
)

func (h *Handler) doReply(w text.Writer, r *Request, args []string, readInput inputFunc) {
if r.User == nil {
w.Redirect("/users")
return
}

postID := "https://" + args[1]

var note ap.Object
Expand Down
10 changes: 10 additions & 0 deletions front/say.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ import (
)

func (h *Handler) say(w text.Writer, r *Request, args ...string) {
if r.User == nil {
w.Redirect("/users")
return
}

to := ap.Audience{}
cc := ap.Audience{}

Expand All @@ -34,6 +39,11 @@ func (h *Handler) say(w text.Writer, r *Request, args ...string) {
}

func (h *Handler) uploadSay(w text.Writer, r *Request, args ...string) {
if r.User == nil {
w.Redirect("/users")
return
}

to := ap.Audience{}
cc := ap.Audience{}

Expand Down
10 changes: 10 additions & 0 deletions front/whisper.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ import (
)

func (h *Handler) whisper(w text.Writer, r *Request, args ...string) {
if r.User == nil {
w.Redirect("/users")
return
}

to := ap.Audience{}
cc := ap.Audience{}

Expand All @@ -33,6 +38,11 @@ func (h *Handler) whisper(w text.Writer, r *Request, args ...string) {
}

func (h *Handler) uploadWhisper(w text.Writer, r *Request, args ...string) {
if r.User == nil {
w.Redirect("/users")
return
}

to := ap.Audience{}
cc := ap.Audience{}

Expand Down

0 comments on commit 2cd60e6

Please sign in to comment.