Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
二次元的罪恶王冠
beego
提交
3ce68d6a
B
beego
项目概览
二次元的罪恶王冠
/
beego
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
beego
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3ce68d6a
编写于
6月 23, 2020
作者:
M
Ming Deng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move many PR's change here since the original authors are responseless
上级
96658121
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
74 addition
and
44 deletion
+74
-44
config.go
config.go
+2
-2
session/sess_file.go
session/sess_file.go
+3
-2
toolbox/task.go
toolbox/task.go
+6
-1
validation/validation_test.go
validation/validation_test.go
+62
-38
validation/validators.go
validation/validators.go
+1
-1
未找到文件。
config.go
浏览文件 @
3ce68d6a
...
...
@@ -420,9 +420,9 @@ func newAppConfig(appConfigProvider, appConfigPath string) (*beegoAppConfig, err
func
(
b
*
beegoAppConfig
)
Set
(
key
,
val
string
)
error
{
if
err
:=
b
.
innerConfig
.
Set
(
BConfig
.
RunMode
+
"::"
+
key
,
val
);
err
!=
nil
{
return
err
return
b
.
innerConfig
.
Set
(
key
,
val
)
}
return
b
.
innerConfig
.
Set
(
key
,
val
)
return
nil
}
func
(
b
*
beegoAppConfig
)
String
(
key
string
)
string
{
...
...
session/sess_file.go
浏览文件 @
3ce68d6a
...
...
@@ -129,8 +129,9 @@ func (fp *FileProvider) SessionInit(maxlifetime int64, savePath string) error {
// if file is not exist, create it.
// the file path is generated from sid string.
func
(
fp
*
FileProvider
)
SessionRead
(
sid
string
)
(
Store
,
error
)
{
if
strings
.
ContainsAny
(
sid
,
"./"
)
{
return
nil
,
nil
invalidChars
:=
"./"
if
strings
.
ContainsAny
(
sid
,
invalidChars
)
{
return
nil
,
errors
.
New
(
"the sid shouldn't have following characters: "
+
invalidChars
)
}
if
len
(
sid
)
<
2
{
return
nil
,
errors
.
New
(
"length of the sid is less than 2"
)
...
...
toolbox/task.go
浏览文件 @
3ce68d6a
...
...
@@ -33,7 +33,7 @@ type bounds struct {
// The bounds for each field.
var
(
AdminTaskList
map
[
string
]
Tasker
taskLock
sync
.
Mutex
taskLock
sync
.
RW
Mutex
stop
chan
bool
changed
chan
bool
isstart
bool
...
...
@@ -408,7 +408,10 @@ func run() {
}
for
{
// we only use RLock here because NewMapSorter copy the reference, do not change any thing
taskLock
.
RLock
()
sortList
:=
NewMapSorter
(
AdminTaskList
)
taskLock
.
RUnlock
()
sortList
.
Sort
()
var
effective
time
.
Time
if
len
(
AdminTaskList
)
==
0
||
sortList
.
Vals
[
0
]
.
GetNext
()
.
IsZero
()
{
...
...
@@ -432,9 +435,11 @@ func run() {
continue
case
<-
changed
:
now
=
time
.
Now
()
.
Local
()
taskLock
.
Lock
()
for
_
,
t
:=
range
AdminTaskList
{
t
.
SetNext
(
now
)
}
taskLock
.
Unlock
()
continue
case
<-
stop
:
return
...
...
validation/validation_test.go
浏览文件 @
3ce68d6a
...
...
@@ -253,44 +253,68 @@ func TestBase64(t *testing.T) {
func
TestMobile
(
t
*
testing
.
T
)
{
valid
:=
Validation
{}
if
valid
.
Mobile
(
"19800008888"
,
"mobile"
)
.
Ok
{
t
.
Error
(
"
\"
19800008888
\"
is a valid mobile phone number should be false"
)
}
if
!
valid
.
Mobile
(
"18800008888"
,
"mobile"
)
.
Ok
{
t
.
Error
(
"
\"
18800008888
\"
is a valid mobile phone number should be true"
)
}
if
!
valid
.
Mobile
(
"18000008888"
,
"mobile"
)
.
Ok
{
t
.
Error
(
"
\"
18000008888
\"
is a valid mobile phone number should be true"
)
}
if
!
valid
.
Mobile
(
"8618300008888"
,
"mobile"
)
.
Ok
{
t
.
Error
(
"
\"
8618300008888
\"
is a valid mobile phone number should be true"
)
}
if
!
valid
.
Mobile
(
"+8614700008888"
,
"mobile"
)
.
Ok
{
t
.
Error
(
"
\"
+8614700008888
\"
is a valid mobile phone number should be true"
)
}
if
!
valid
.
Mobile
(
"17300008888"
,
"mobile"
)
.
Ok
{
t
.
Error
(
"
\"
17300008888
\"
is a valid mobile phone number should be true"
)
}
if
!
valid
.
Mobile
(
"+8617100008888"
,
"mobile"
)
.
Ok
{
t
.
Error
(
"
\"
+8617100008888
\"
is a valid mobile phone number should be true"
)
}
if
!
valid
.
Mobile
(
"8617500008888"
,
"mobile"
)
.
Ok
{
t
.
Error
(
"
\"
8617500008888
\"
is a valid mobile phone number should be true"
)
}
if
valid
.
Mobile
(
"8617400008888"
,
"mobile"
)
.
Ok
{
t
.
Error
(
"
\"
8617400008888
\"
is a valid mobile phone number should be false"
)
}
if
!
valid
.
Mobile
(
"16200008888"
,
"mobile"
)
.
Ok
{
t
.
Error
(
"
\"
16200008888
\"
is a valid mobile phone number should be true"
)
}
if
!
valid
.
Mobile
(
"16500008888"
,
"mobile"
)
.
Ok
{
t
.
Error
(
"
\"
16500008888
\"
is a valid mobile phone number should be true"
)
}
if
!
valid
.
Mobile
(
"16600008888"
,
"mobile"
)
.
Ok
{
t
.
Error
(
"
\"
16600008888
\"
is a valid mobile phone number should be true"
)
}
if
!
valid
.
Mobile
(
"16700008888"
,
"mobile"
)
.
Ok
{
t
.
Error
(
"
\"
16700008888
\"
is a valid mobile phone number should be true"
)
validMobiles
:=
[]
string
{
"19800008888"
,
"18800008888"
,
"18000008888"
,
"8618300008888"
,
"+8614700008888"
,
"17300008888"
,
"+8617100008888"
,
"8617500008888"
,
"8617400008888"
,
"16200008888"
,
"16500008888"
,
"16600008888"
,
"16700008888"
,
"13300008888"
,
"14900008888"
,
"15300008888"
,
"17300008888"
,
"17700008888"
,
"18000008888"
,
"18900008888"
,
"19100008888"
,
"19900008888"
,
"19300008888"
,
"13000008888"
,
"13100008888"
,
"13200008888"
,
"14500008888"
,
"15500008888"
,
"15600008888"
,
"16600008888"
,
"17100008888"
,
"17500008888"
,
"17600008888"
,
"18500008888"
,
"18600008888"
,
"13400008888"
,
"13500008888"
,
"13600008888"
,
"13700008888"
,
"13800008888"
,
"13900008888"
,
"14700008888"
,
"15000008888"
,
"15100008888"
,
"15200008888"
,
"15800008888"
,
"15900008888"
,
"17200008888"
,
"17800008888"
,
"18200008888"
,
"18300008888"
,
"18400008888"
,
"18700008888"
,
"18800008888"
,
"19800008888"
,
}
for
_
,
m
:=
range
validMobiles
{
if
!
valid
.
Mobile
(
m
,
"mobile"
)
.
Ok
{
t
.
Error
(
m
+
" is a valid mobile phone number should be true"
)
}
}
}
...
...
validation/validators.go
浏览文件 @
3ce68d6a
...
...
@@ -632,7 +632,7 @@ func (b Base64) GetLimitValue() interface{} {
}
// just for chinese mobile phone number
var
mobilePattern
=
regexp
.
MustCompile
(
`^((\+86)|(86))?
(1(([35][0-9])|[8][0-9]|[7][01356789]|[4][579]|[6][2567]))\d
{8}$`
)
var
mobilePattern
=
regexp
.
MustCompile
(
`^((\+86)|(86))?
1([356789][0-9]|4[579]|6[67]|7[0135678]|9[189])[0-9]
{8}$`
)
// Mobile check struct
type
Mobile
struct
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录