From 6807aaee3dc2f73c7a4eb33ec2580e9cb7b39854 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sat, 2 Mar 2019 10:21:45 -0500 Subject: [PATCH] fix stuff and add uri in post form --- contrib/backends/srndv2/src/srnd/frontend_http.go | 11 ++++++++++- contrib/templates/default/postform.mustache | 9 +++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/contrib/backends/srndv2/src/srnd/frontend_http.go b/contrib/backends/srndv2/src/srnd/frontend_http.go index b4562b6..b9a4a7e 100644 --- a/contrib/backends/srndv2/src/srnd/frontend_http.go +++ b/contrib/backends/srndv2/src/srnd/frontend_http.go @@ -437,6 +437,7 @@ func (self *httpFrontend) handle_postform(wr http.ResponseWriter, r *http.Reques // the post we will turn into an nntp article pr := new(postRequest) + pr.ExtraHeaders = make(map[string]string) if sendJson { wr.Header().Add("Content-Type", "text/json; encoding=UTF-8") @@ -520,6 +521,11 @@ func (self *httpFrontend) handle_postform(wr http.ResponseWriter, r *http.Reques captcha_solution = part_buff.String() } else if partname == "dubs" { pr.Dubs = part_buff.String() == "on" + } else if partname == "uri" { + str := part_buff.String() + if len(str) > 0 { + pr.ExtraHeaders["X-References-Uri"] = safeHeader(str) + } } // we done @@ -552,6 +558,8 @@ func (self *httpFrontend) handle_postform(wr http.ResponseWriter, r *http.Reques cid, ok := sess.Values["captcha_id"] if ok { captcha_id = cid.(string) + } else { + log.Println("no captcha id in session?") } sess.Values["captcha_id"] = "" } @@ -974,6 +982,7 @@ func (self *httpFrontend) serve_captcha(wr http.ResponseWriter, r *http.Request) if err == nil { captcha_id := captcha.New() s.Values["captcha_id"] = captcha_id + log.Println("captcha_id", captcha_id) s.Save(r, wr) redirect_url := fmt.Sprintf("%scaptcha/%s.png", self.prefix, captcha_id) // redirect to the image @@ -1543,7 +1552,7 @@ func NewHTTPFrontend(daemon *NNTPDaemon, cache CacheInterface, config map[string front.store = sessions.NewCookieStore([]byte(front.secret)) front.store.Options = &sessions.Options{ // TODO: detect http:// etc in prefix - Path: front.prefix, + Path: "/", MaxAge: 600, } diff --git a/contrib/templates/default/postform.mustache b/contrib/templates/default/postform.mustache index d4c5ea8..1a3b753 100644 --- a/contrib/templates/default/postform.mustache +++ b/contrib/templates/default/postform.mustache @@ -43,6 +43,15 @@ + + + Link URI + + + + + + {{#files}}