Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
d35a99e6
Commit
d35a99e6
authored
Jul 02, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7204 from cirosantilli/user-validation-msg
Fix username validation message to match regexp.
parents
f3b31c4c
b1c40e81
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
6 deletions
+32
-6
app/models/namespace.rb
app/models/namespace.rb
+2
-2
app/models/project.rb
app/models/project.rb
+2
-2
app/models/user.rb
app/models/user.rb
+1
-1
app/services/files/create_service.rb
app/services/files/create_service.rb
+4
-1
lib/gitlab/regex.rb
lib/gitlab/regex.rb
+23
-0
No files found.
app/models/namespace.rb
View file @
d35a99e6
...
@@ -23,12 +23,12 @@ class Namespace < ActiveRecord::Base
...
@@ -23,12 +23,12 @@ class Namespace < ActiveRecord::Base
validates
:name
,
presence:
true
,
uniqueness:
true
,
validates
:name
,
presence:
true
,
uniqueness:
true
,
length:
{
within:
0
..
255
},
length:
{
within:
0
..
255
},
format:
{
with:
Gitlab
::
Regex
.
name_regex
,
format:
{
with:
Gitlab
::
Regex
.
name_regex
,
message:
"only letters, digits, spaces & '_' '-' '.' allowed."
}
message:
Gitlab
::
Regex
.
name_regex_message
}
validates
:description
,
length:
{
within:
0
..
255
}
validates
:description
,
length:
{
within:
0
..
255
}
validates
:path
,
uniqueness:
{
case_sensitive:
false
},
presence:
true
,
length:
{
within:
1
..
255
},
validates
:path
,
uniqueness:
{
case_sensitive:
false
},
presence:
true
,
length:
{
within:
1
..
255
},
exclusion:
{
in:
Gitlab
::
Blacklist
.
path
},
exclusion:
{
in:
Gitlab
::
Blacklist
.
path
},
format:
{
with:
Gitlab
::
Regex
.
path_regex
,
format:
{
with:
Gitlab
::
Regex
.
path_regex
,
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
message:
Gitlab
::
Regex
.
path_regex_message
}
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
...
...
app/models/project.rb
View file @
d35a99e6
...
@@ -90,11 +90,11 @@ class Project < ActiveRecord::Base
...
@@ -90,11 +90,11 @@ class Project < ActiveRecord::Base
validates
:description
,
length:
{
maximum:
2000
},
allow_blank:
true
validates
:description
,
length:
{
maximum:
2000
},
allow_blank:
true
validates
:name
,
presence:
true
,
length:
{
within:
0
..
255
},
validates
:name
,
presence:
true
,
length:
{
within:
0
..
255
},
format:
{
with:
Gitlab
::
Regex
.
project_name_regex
,
format:
{
with:
Gitlab
::
Regex
.
project_name_regex
,
message:
"only letters, digits, spaces & '_' '-' '.' allowed. Letter or digit should be first"
}
message:
Gitlab
::
Regex
.
project_regex_message
}
validates
:path
,
presence:
true
,
length:
{
within:
0
..
255
},
validates
:path
,
presence:
true
,
length:
{
within:
0
..
255
},
exclusion:
{
in:
Gitlab
::
Blacklist
.
path
},
exclusion:
{
in:
Gitlab
::
Blacklist
.
path
},
format:
{
with:
Gitlab
::
Regex
.
path_regex
,
format:
{
with:
Gitlab
::
Regex
.
path_regex
,
message:
"only letters, digits & '_' '-' '.' allowed. Letter or digit should be first"
}
message:
Gitlab
::
Regex
.
path_regex_message
}
validates
:issues_enabled
,
:merge_requests_enabled
,
validates
:issues_enabled
,
:merge_requests_enabled
,
:wiki_enabled
,
inclusion:
{
in:
[
true
,
false
]
}
:wiki_enabled
,
inclusion:
{
in:
[
true
,
false
]
}
validates
:visibility_level
,
validates
:visibility_level
,
...
...
app/models/user.rb
View file @
d35a99e6
...
@@ -113,7 +113,7 @@ class User < ActiveRecord::Base
...
@@ -113,7 +113,7 @@ class User < ActiveRecord::Base
validates
:username
,
presence:
true
,
uniqueness:
{
case_sensitive:
false
},
validates
:username
,
presence:
true
,
uniqueness:
{
case_sensitive:
false
},
exclusion:
{
in:
Gitlab
::
Blacklist
.
path
},
exclusion:
{
in:
Gitlab
::
Blacklist
.
path
},
format:
{
with:
Gitlab
::
Regex
.
username_regex
,
format:
{
with:
Gitlab
::
Regex
.
username_regex
,
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
message:
Gitlab
::
Regex
.
username_regex_message
}
validates
:notification_level
,
inclusion:
{
in:
Notification
.
notification_levels
},
presence:
true
validates
:notification_level
,
inclusion:
{
in:
Notification
.
notification_levels
},
presence:
true
validate
:namespace_uniq
,
if:
->
(
user
)
{
user
.
username_changed?
}
validate
:namespace_uniq
,
if:
->
(
user
)
{
user
.
username_changed?
}
...
...
app/services/files/create_service.rb
View file @
d35a99e6
...
@@ -21,7 +21,10 @@ module Files
...
@@ -21,7 +21,10 @@ module Files
file_path
=
path
file_path
=
path
unless
file_name
=~
Gitlab
::
Regex
.
path_regex
unless
file_name
=~
Gitlab
::
Regex
.
path_regex
return
error
(
"Your changes could not be committed, because file name contains not allowed characters"
)
return
error
(
'Your changes could not be committed, because the file name '
+
Gitlab
::
Regex
.
path_regex_message
)
end
end
blob
=
repository
.
blob_at_branch
(
ref
,
file_path
)
blob
=
repository
.
blob_at_branch
(
ref
,
file_path
)
...
...
lib/gitlab/regex.rb
View file @
d35a99e6
...
@@ -6,18 +6,35 @@ module Gitlab
...
@@ -6,18 +6,35 @@ module Gitlab
default_regex
default_regex
end
end
def
username_regex_message
default_regex_message
end
def
project_name_regex
def
project_name_regex
/\A[a-zA-Z0-9_][a-zA-Z0-9_\-\. ]*\z/
/\A[a-zA-Z0-9_][a-zA-Z0-9_\-\. ]*\z/
end
end
def
project_regex_message
"can contain only letters, digits, '_', '-' and '.' and space. "
\
"It must start with letter, digit or '_'."
end
def
name_regex
def
name_regex
/\A[a-zA-Z0-9_\-\. ]*\z/
/\A[a-zA-Z0-9_\-\. ]*\z/
end
end
def
name_regex_message
"can contain only letters, digits, '_', '-' and '.' and space."
end
def
path_regex
def
path_regex
default_regex
default_regex
end
end
def
path_regex_message
default_regex_message
end
def
archive_formats_regex
def
archive_formats_regex
#|zip|tar| tar.gz | tar.bz2 |
#|zip|tar| tar.gz | tar.bz2 |
/(zip|tar|tar\.gz|tgz|gz|tar\.bz2|tbz|tbz2|tb2|bz2)/
/(zip|tar|tar\.gz|tgz|gz|tar\.bz2|tbz|tbz2|tb2|bz2)/
...
@@ -48,6 +65,12 @@ module Gitlab
...
@@ -48,6 +65,12 @@ module Gitlab
protected
protected
def
default_regex_message
"can contain only letters, digits, '_', '-' and '.'. "
\
"It must start with letter, digit or '_', optionally preceeded by '.'. "
\
"It must not end in '.git'."
end
def
default_regex
def
default_regex
/\A[.?]?[a-zA-Z0-9_][a-zA-Z0-9_\-\.]*(?<!\.git)\z/
/\A[.?]?[a-zA-Z0-9_][a-zA-Z0-9_\-\.]*(?<!\.git)\z/
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment