aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-05-01 07:35:21 -0400
committerUnknown <joe2010xtmf@163.com>2014-05-01 07:35:21 -0400
commit2a1dc0085b9f7236082f3885fa594ec12d5b0211 (patch)
treea81b38f0e3ac9835519a1057c98813c1ead49ac9
parent46af92c57e0d0d71f45d13d0b4bacb91ed2db16b (diff)
downloadgitea-2a1dc0085b9f7236082f3885fa594ec12d5b0211.tar.gz
gitea-2a1dc0085b9f7236082f3885fa594ec12d5b0211.zip
fix #91
-rw-r--r--modules/auth/auth.go4
-rw-r--r--modules/base/base.go1
-rw-r--r--modules/middleware/binding.go12
-rw-r--r--templates/base/navbar.tmpl2
4 files changed, 14 insertions, 5 deletions
diff --git a/modules/auth/auth.go b/modules/auth/auth.go
index e493faefe7..85df42d8c4 100644
--- a/modules/auth/auth.go
+++ b/modules/auth/auth.go
@@ -21,7 +21,7 @@ type Form interface {
}
type RegisterForm struct {
- UserName string `form:"username" binding:"Required;AlphaDash;MaxSize(30)"`
+ UserName string `form:"username" binding:"Required;AlphaDashDot;MaxSize(30)"`
Email string `form:"email" binding:"Required;Email;MaxSize(50)"`
Password string `form:"passwd" binding:"Required;MinSize(6);MaxSize(30)"`
RetypePasswd string `form:"retypepasswd"`
@@ -123,6 +123,8 @@ func validate(errors *base.BindingErrors, data base.TmplData, form Form) {
data["ErrorMsg"] = form.Name(field.Name) + " cannot be empty"
case base.BindingAlphaDashError:
data["ErrorMsg"] = form.Name(field.Name) + " must be valid alpha or numeric or dash(-_) characters"
+ case base.BindingAlphaDashDotError:
+ data["ErrorMsg"] = form.Name(field.Name) + " must be valid alpha or numeric or dash(-_) or dot characters"
case base.BindingMinSizeError:
data["ErrorMsg"] = form.Name(field.Name) + " must contain at least " + getMinMaxSize(field) + " characters"
case base.BindingMaxSizeError:
diff --git a/modules/base/base.go b/modules/base/base.go
index 3e80a436e4..e6befb83fd 100644
--- a/modules/base/base.go
+++ b/modules/base/base.go
@@ -45,6 +45,7 @@ func (this *BindingErrors) Combine(other BindingErrors) {
const (
BindingRequireError string = "Required"
BindingAlphaDashError string = "AlphaDash"
+ BindingAlphaDashDotError string = "AlphaDashDot"
BindingMinSizeError string = "MinSize"
BindingMaxSizeError string = "MaxSize"
BindingEmailError string = "Email"
diff --git a/modules/middleware/binding.go b/modules/middleware/binding.go
index cde9ae9cc0..bff34ddde0 100644
--- a/modules/middleware/binding.go
+++ b/modules/middleware/binding.go
@@ -180,9 +180,10 @@ func Validate(obj interface{}) martini.Handler {
}
var (
- alphaDashPattern = regexp.MustCompile("[^\\d\\w-_]")
- emailPattern = regexp.MustCompile("[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[a-zA-Z0-9](?:[\\w-]*[\\w])?")
- urlPattern = regexp.MustCompile(`(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?`)
+ alphaDashPattern = regexp.MustCompile("[^\\d\\w-_]")
+ alphaDashDotPattern = regexp.MustCompile("[^\\d\\w-_\\.]")
+ emailPattern = regexp.MustCompile("[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[a-zA-Z0-9](?:[\\w-]*[\\w])?")
+ urlPattern = regexp.MustCompile(`(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?`)
)
func validateStruct(errors *base.BindingErrors, obj interface{}) {
@@ -227,6 +228,11 @@ func validateStruct(errors *base.BindingErrors, obj interface{}) {
errors.Fields[field.Name] = base.BindingAlphaDashError
break
}
+ case rule == "AlphaDashDot":
+ if alphaDashDotPattern.MatchString(fmt.Sprintf("%v", fieldValue)) {
+ errors.Fields[field.Name] = base.BindingAlphaDashDotError
+ break
+ }
case strings.HasPrefix(rule, "MinSize("):
min, err := strconv.Atoi(rule[8 : len(rule)-1])
if err != nil {
diff --git a/templates/base/navbar.tmpl b/templates/base/navbar.tmpl
index da6865b8e8..80085d974a 100644
--- a/templates/base/navbar.tmpl
+++ b/templates/base/navbar.tmpl
@@ -3,7 +3,7 @@
<nav class="nav">
<a id="nav-logo" class="nav-item pull-left{{if .PageIsHome}} active{{end}}" href="/"><img src="/img/favicon.png" alt="Gogs Logo" id="logo"></a>
<a class="nav-item pull-left{{if .PageIsUserDashboard}} active{{end}}" href="/">Dashboard</a>
- <a class="nav-item pull-left{{if .PageIsHelp}} active{{end}}" target="_blank" href="https://github.com/gogits/gogs/wiki">Help</a>{{if .IsSigned}}
+ <a class="nav-item pull-left{{if .PageIsHelp}} active{{end}}" target="_blank" href="http://gogs.io/docs">Help</a>{{if .IsSigned}}
{{if .HasAccess}}<form class="nav-item pull-left{{if .PageIsNewRepo}} active{{end}}" id="nav-search-form">
<div class="input-group">
<div class="input-group-btn">