Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
d35a99e6
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d35a99e6
编写于
7月 02, 2014
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7204 from cirosantilli/user-validation-msg
Fix username validation message to match regexp.
上级
f3b31c4c
b1c40e81
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
32 addition
and
6 deletion
+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
未找到文件。
app/models/namespace.rb
浏览文件 @
d35a99e6
...
...
@@ -23,12 +23,12 @@ class Namespace < ActiveRecord::Base
validates
:name
,
presence:
true
,
uniqueness:
true
,
length:
{
within:
0
..
255
},
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
:path
,
uniqueness:
{
case_sensitive:
false
},
presence:
true
,
length:
{
within:
1
..
255
},
exclusion:
{
in:
Gitlab
::
Blacklist
.
path
},
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
...
...
app/models/project.rb
浏览文件 @
d35a99e6
...
...
@@ -90,11 +90,11 @@ class Project < ActiveRecord::Base
validates
:description
,
length:
{
maximum:
2000
},
allow_blank:
true
validates
:name
,
presence:
true
,
length:
{
within:
0
..
255
},
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
},
exclusion:
{
in:
Gitlab
::
Blacklist
.
path
},
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
,
:wiki_enabled
,
inclusion:
{
in:
[
true
,
false
]
}
validates
:visibility_level
,
...
...
app/models/user.rb
浏览文件 @
d35a99e6
...
...
@@ -113,7 +113,7 @@ class User < ActiveRecord::Base
validates
:username
,
presence:
true
,
uniqueness:
{
case_sensitive:
false
},
exclusion:
{
in:
Gitlab
::
Blacklist
.
path
},
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
validate
:namespace_uniq
,
if:
->
(
user
)
{
user
.
username_changed?
}
...
...
app/services/files/create_service.rb
浏览文件 @
d35a99e6
...
...
@@ -21,7 +21,10 @@ module Files
file_path
=
path
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
blob
=
repository
.
blob_at_branch
(
ref
,
file_path
)
...
...
lib/gitlab/regex.rb
浏览文件 @
d35a99e6
...
...
@@ -6,18 +6,35 @@ module Gitlab
default_regex
end
def
username_regex_message
default_regex_message
end
def
project_name_regex
/\A[a-zA-Z0-9_][a-zA-Z0-9_\-\. ]*\z/
end
def
project_regex_message
"can contain only letters, digits, '_', '-' and '.' and space. "
\
"It must start with letter, digit or '_'."
end
def
name_regex
/\A[a-zA-Z0-9_\-\. ]*\z/
end
def
name_regex_message
"can contain only letters, digits, '_', '-' and '.' and space."
end
def
path_regex
default_regex
end
def
path_regex_message
default_regex_message
end
def
archive_formats_regex
#|zip|tar| tar.gz | tar.bz2 |
/(zip|tar|tar\.gz|tgz|gz|tar\.bz2|tbz|tbz2|tb2|bz2)/
...
...
@@ -48,6 +65,12 @@ module Gitlab
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
/\A[.?]?[a-zA-Z0-9_][a-zA-Z0-9_\-\.]*(?<!\.git)\z/
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录