From 99177a59c33cf3ea7877d9ed66a4ab1ccd2fe7c4 Mon Sep 17 00:00:00 2001 From: JBP <2850825+JyBP@users.noreply.github.com> Date: Thu, 9 Aug 2018 11:09:42 +0200 Subject: [PATCH] commenter_new.go: do not return error on empty website Closes https://gitlab.com/commento/commento-ce/issues/57 --- api/commenter_new.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/api/commenter_new.go b/api/commenter_new.go index d3d1045..9d8590d 100644 --- a/api/commenter_new.go +++ b/api/commenter_new.go @@ -1,9 +1,10 @@ package main import ( - "golang.org/x/crypto/bcrypt" "net/http" "time" + + "golang.org/x/crypto/bcrypt" ) func commenterNew(email string, name string, link string, photo string, provider string, password string) (string, error) { @@ -18,7 +19,7 @@ func commenterNew(email string, name string, link string, photo string, provider // See utils_sanitise.go's documentation on isHttpsUrl. This is not a URL // validator, just an XSS preventor. // TODO: reject URLs instead of malforming them. - if !isHttpsUrl(link) { + if link != "undefined" && !isHttpsUrl(link) { link = "https://" + link } @@ -71,6 +72,10 @@ func commenterNewHandler(w http.ResponseWriter, r *http.Request) { // TODO: add gravatar? // TODO: email confirmation if provider = commento? // TODO: email confirmation if provider = commento? + if *x.Website == "" { + *x.Website = "undefined" + } + if _, err := commenterNew(*x.Email, *x.Name, *x.Website, "undefined", "commento", *x.Password); err != nil { bodyMarshal(w, response{"success": false, "message": err.Error()}) return