Archived
1
0

fix stuff and add uri in post form

This commit is contained in:
Jeff Becker 2019-03-02 10:21:45 -05:00
parent a00630a6b3
commit 6807aaee3d
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
2 changed files with 19 additions and 1 deletions

View File

@ -437,6 +437,7 @@ func (self *httpFrontend) handle_postform(wr http.ResponseWriter, r *http.Reques
// the post we will turn into an nntp article // the post we will turn into an nntp article
pr := new(postRequest) pr := new(postRequest)
pr.ExtraHeaders = make(map[string]string)
if sendJson { if sendJson {
wr.Header().Add("Content-Type", "text/json; encoding=UTF-8") 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() captcha_solution = part_buff.String()
} else if partname == "dubs" { } else if partname == "dubs" {
pr.Dubs = part_buff.String() == "on" 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 // we done
@ -552,6 +558,8 @@ func (self *httpFrontend) handle_postform(wr http.ResponseWriter, r *http.Reques
cid, ok := sess.Values["captcha_id"] cid, ok := sess.Values["captcha_id"]
if ok { if ok {
captcha_id = cid.(string) captcha_id = cid.(string)
} else {
log.Println("no captcha id in session?")
} }
sess.Values["captcha_id"] = "" sess.Values["captcha_id"] = ""
} }
@ -974,6 +982,7 @@ func (self *httpFrontend) serve_captcha(wr http.ResponseWriter, r *http.Request)
if err == nil { if err == nil {
captcha_id := captcha.New() captcha_id := captcha.New()
s.Values["captcha_id"] = captcha_id s.Values["captcha_id"] = captcha_id
log.Println("captcha_id", captcha_id)
s.Save(r, wr) s.Save(r, wr)
redirect_url := fmt.Sprintf("%scaptcha/%s.png", self.prefix, captcha_id) redirect_url := fmt.Sprintf("%scaptcha/%s.png", self.prefix, captcha_id)
// redirect to the image // 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 = sessions.NewCookieStore([]byte(front.secret))
front.store.Options = &sessions.Options{ front.store.Options = &sessions.Options{
// TODO: detect http:// etc in prefix // TODO: detect http:// etc in prefix
Path: front.prefix, Path: "/",
MaxAge: 600, MaxAge: 600,
} }

View File

@ -43,6 +43,15 @@
<textarea id="postform_message" name="message" cols=40 rows=5></textarea> <textarea id="postform_message" name="message" cols=40 rows=5></textarea>
</td> </td>
</tr> </tr>
<tr>
<th>
Link URI
</th>
<td>
<input id="postform_uri" name="uri" value="" type="text" />
</td>
</tr>
{{#files}} {{#files}}
<tr> <tr>
<th> <th>