Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
0ea38dc5
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,体验更适合开发者的 AI 搜索 >>
提交
0ea38dc5
编写于
10月 29, 2015
作者:
D
Douwe Maan
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'binford2k/gitlab-ce-feature/create_new_directories'
上级
f24324ad
6d0337a9
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
66 addition
and
5 deletion
+66
-5
CHANGELOG
CHANGELOG
+3
-0
app/assets/stylesheets/pages/editor.scss
app/assets/stylesheets/pages/editor.scss
+1
-1
app/controllers/projects/blob_controller.rb
app/controllers/projects/blob_controller.rb
+1
-1
app/services/files/create_dir_service.rb
app/services/files/create_dir_service.rb
+11
-0
app/services/files/create_service.rb
app/services/files/create_service.rb
+8
-3
features/project/source/browse_files.feature
features/project/source/browse_files.feature
+10
-0
features/steps/project/source/browse_files.rb
features/steps/project/source/browse_files.rb
+15
-0
lib/gitlab/regex.rb
lib/gitlab/regex.rb
+17
-0
未找到文件。
CHANGELOG
浏览文件 @
0ea38dc5
...
...
@@ -30,6 +30,9 @@ v 8.1.0
- Ensure MySQL CI limits DB migrations occur after the fields have been created (Stan Hu)
- Fix duplicate repositories in GitHub import page (Stan Hu)
- Redirect to a default path if HTTP_REFERER is not set (Stan Hu)
- Adds ability to create directories using the web editor (Ben Ford)
v 8.1.0 (unreleased)
- Send an email to admin email when a user is reported for spam (Jonathan Rochkind)
- Show notifications button when user is member of group rather than project (Grzegorz Bizon)
- Fix bug preventing mentioned issued from being closed when MR is merged using fast-forward merge.
...
...
app/assets/stylesheets/pages/editor.scss
浏览文件 @
0ea38dc5
...
...
@@ -50,7 +50,7 @@
.editor-file-name
{
.new-file-name
{
display
:
inline-block
;
width
:
20
0px
;
width
:
45
0px
;
}
.form-control
{
...
...
app/controllers/projects/blob_controller.rb
浏览文件 @
0ea38dc5
...
...
@@ -161,7 +161,7 @@ class Projects::BlobController < Projects::ApplicationController
if
params
[
:file
].
present?
params
[
:file_name
]
=
params
[
:file
].
original_filename
end
File
.
join
(
@path
,
File
.
basename
(
params
[
:file_name
])
)
File
.
join
(
@path
,
params
[
:file_name
]
)
else
@path
end
...
...
app/services/files/create_dir_service.rb
浏览文件 @
0ea38dc5
...
...
@@ -5,5 +5,16 @@ module Files
def
commit
repository
.
commit_dir
(
current_user
,
@file_path
,
@commit_message
,
@target_branch
)
end
def
validate
super
unless
@file_path
=~
Gitlab
::
Regex
.
file_path_regex
raise_error
(
'Your changes could not be committed, because the file path '
+
Gitlab
::
Regex
.
file_path_regex_message
)
end
end
end
end
app/services/files/create_service.rb
浏览文件 @
0ea38dc5
...
...
@@ -9,12 +9,17 @@ module Files
def
validate
super
file_name
=
File
.
basename
(
@file_path
)
if
@file_path
=~
Gitlab
::
Regex
.
directory_traversal_regex
raise_error
(
'Your changes could not be committed, because the file name '
+
Gitlab
::
Regex
.
directory_traversal_regex_message
)
end
unless
file_name
=~
Gitlab
::
Regex
.
file_name
_regex
unless
@file_path
=~
Gitlab
::
Regex
.
file_path
_regex
raise_error
(
'Your changes could not be committed, because the file name '
+
Gitlab
::
Regex
.
file_
name
_regex_message
Gitlab
::
Regex
.
file_
path
_regex_message
)
end
...
...
features/project/source/browse_files.feature
浏览文件 @
0ea38dc5
...
...
@@ -90,6 +90,16 @@ Feature: Project Source Browse Files
Then
I am on the new file page
And
I see a commit error message
@javascript
Scenario
:
I
can create file with a directory name
Given
I click on
"New file"
link in repo
And
I fill the new file name with a new directory
And
I edit code
And
I fill the commit message
And
I click on
"Commit changes"
Then
I am redirected to the new file with directory
And
I should see its new content
@javascript
Scenario
:
I
can edit file
Given
I click on
".gitignore"
file in repo
...
...
features/steps/project/source/browse_files.rb
浏览文件 @
0ea38dc5
...
...
@@ -78,6 +78,10 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
fill_in
:file_name
,
with:
'Spaces Not Allowed'
end
step
'I fill the new file name with a new directory'
do
fill_in
:file_name
,
with:
new_file_name_with_directory
end
step
'I fill the commit message'
do
fill_in
:commit_message
,
with:
'Not yet a commit message.'
,
visible:
true
end
...
...
@@ -238,6 +242,11 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
@project
.
namespace
,
@project
,
'master/'
+
new_file_name
))
end
step
'I am redirected to the new file with directory'
do
expect
(
current_path
).
to
eq
(
namespace_project_blob_path
(
@project
.
namespace
,
@project
,
'master/'
+
new_file_name_with_directory
))
end
step
'I am redirected to the new file on new branch'
do
expect
(
current_path
).
to
eq
(
namespace_project_blob_path
(
@project
.
namespace
,
@project
,
'new_branch_name/'
+
new_file_name
))
...
...
@@ -335,6 +344,12 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
'not_a_file.md'
end
# Constant value that is a valid filename with directory and
# not a filename present at root of the seed repository.
def
new_file_name_with_directory
'foo/bar/baz.txt'
end
# Constant value that is a valid directory and
# not a directory present at root of the seed repository.
def
new_dir_name
...
...
lib/gitlab/regex.rb
浏览文件 @
0ea38dc5
...
...
@@ -51,6 +51,23 @@ module Gitlab
"can contain only letters, digits, '_', '-' and '.'. "
end
def
file_path_regex
@file_path_regex
||=
/\A[a-zA-Z0-9_\-\.\/]*\z/
.
freeze
end
def
file_path_regex_message
"can contain only letters, digits, '_', '-' and '.'. Separate directories with a '/'. "
end
def
directory_traversal_regex
@directory_traversal_regex
||=
/\.{2}/
.
freeze
end
def
directory_traversal_regex_message
"cannot include directory traversal. "
end
def
archive_formats_regex
# |zip|tar| tar.gz | tar.bz2 |
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录