Compare commits
2 Commits
5080c566ac
...
ad30583265
Author | SHA1 | Date |
---|---|---|
Elizabeth Hunt | ad30583265 | |
Elizabeth Hunt | 2c6b124664 |
|
@ -27,8 +27,8 @@ func validateGuestbookEntry(entry *database.GuestbookEntry) []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
messageLength := len(entry.Message)
|
messageLength := len(entry.Message)
|
||||||
if messageLength < 10 || messageLength > 500 {
|
if messageLength > 500 {
|
||||||
errors = append(errors, "message must be between 10 and 500 characters")
|
errors = append(errors, "message cannot be longer than 500 characters")
|
||||||
}
|
}
|
||||||
|
|
||||||
newLines := strings.Count(entry.Message, "\n")
|
newLines := strings.Count(entry.Message, "\n")
|
||||||
|
@ -58,19 +58,17 @@ func SignGuestbookContinuation(context *RequestContext, req *http.Request, resp
|
||||||
Name: name,
|
Name: name,
|
||||||
Message: message,
|
Message: message,
|
||||||
}
|
}
|
||||||
|
|
||||||
formErrors.Errors = append(formErrors.Errors, validateGuestbookEntry(entry)...)
|
formErrors.Errors = append(formErrors.Errors, validateGuestbookEntry(entry)...)
|
||||||
|
|
||||||
if len(formErrors.Errors) > 0 {
|
|
||||||
(*context.TemplateData)["FormError"] = formErrors
|
|
||||||
return failure(context, req, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
err := verifyHCaptcha(context.Args.HcaptchaSecret, hCaptchaResponse)
|
err := verifyHCaptcha(context.Args.HcaptchaSecret, hCaptchaResponse)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
|
||||||
resp.WriteHeader(http.StatusBadRequest)
|
formErrors.Errors = append(formErrors.Errors, "hCaptcha verification failed")
|
||||||
|
}
|
||||||
|
if len(formErrors.Errors) > 0 {
|
||||||
|
(*context.TemplateData)["FormError"] = formErrors
|
||||||
|
(*context.TemplateData)["EntryForm"] = entry
|
||||||
return failure(context, req, resp)
|
return failure(context, req, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,12 @@ func resolveRecursive(dbConn *sql.DB, dnsResolvers []string, domain string, qtyp
|
||||||
|
|
||||||
answers := []dns.RR{}
|
answers := []dns.RR{}
|
||||||
for _, record := range internalCnames {
|
for _, record := range internalCnames {
|
||||||
|
cname, err := dns.NewRR(fmt.Sprintf("%s %d IN CNAME %s", record.Name, record.TTL, record.Content))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
answers = append(answers, cname)
|
||||||
|
|
||||||
cnameRecursive, _ := resolveRecursive(dbConn, dnsResolvers, record.Content, qtype, maxDepth-1)
|
cnameRecursive, _ := resolveRecursive(dbConn, dnsResolvers, record.Content, qtype, maxDepth-1)
|
||||||
answers = append(answers, cnameRecursive...)
|
answers = append(answers, cnameRecursive...)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,7 @@
|
||||||
{{ if not .EntryForm }}
|
{{ if not .EntryForm }}
|
||||||
placeholder="hoi!"
|
placeholder="hoi!"
|
||||||
{{ end }}
|
{{ end }}
|
||||||
>{{ if .EntryForm }}{{ .EntryForm.Message }}{{ end }}
|
>{{ if .EntryForm }}{{ .EntryForm.Message }}{{ end }}</textarea>
|
||||||
</textarea>
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="h-captcha"
|
class="h-captcha"
|
||||||
data-sitekey="{{ .HcaptchaArgs.SiteKey }}"
|
data-sitekey="{{ .HcaptchaArgs.SiteKey }}"
|
||||||
|
|
Loading…
Reference in New Issue