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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
02007866
Commit
02007866
authored
Feb 18, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent xss attack over group name. Added regex validation for group and team name
parent
cfdf94fc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
6 deletions
+22
-6
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+7
-2
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+1
-1
app/models/namespace.rb
app/models/namespace.rb
+6
-2
app/models/user_team.rb
app/models/user_team.rb
+4
-1
lib/gitlab/regex.rb
lib/gitlab/regex.rb
+4
-0
No files found.
app/helpers/application_helper.rb
View file @
02007866
...
...
@@ -73,8 +73,8 @@ module ApplicationHelper
def
search_autocomplete_source
projects
=
current_user
.
authorized_projects
.
map
{
|
p
|
{
label:
"project:
#{
p
.
name_with_namespace
}
"
,
url:
project_path
(
p
)
}
}
groups
=
current_user
.
authorized_groups
.
map
{
|
group
|
{
label:
"group:
#{
group
.
name
}
"
,
url:
group_path
(
group
)
}
}
teams
=
current_user
.
authorized_teams
.
map
{
|
team
|
{
label:
"team:
#{
team
.
name
}
"
,
url:
team_path
(
team
)
}
}
groups
=
current_user
.
authorized_groups
.
map
{
|
group
|
{
label:
"group:
#{
simple_sanitize
(
group
.
name
)
}
"
,
url:
group_path
(
group
)
}
}
teams
=
current_user
.
authorized_teams
.
map
{
|
team
|
{
label:
"team:
#{
simple_sanitize
(
team
.
name
)
}
"
,
url:
team_path
(
team
)
}
}
default_nav
=
[
{
label:
"My Profile"
,
url:
profile_path
},
...
...
@@ -159,8 +159,13 @@ module ApplicationHelper
alt:
"Sign in with
#{
provider
.
to_s
.
titleize
}
"
)
end
def
simple_sanitize
str
sanitize
(
str
,
tags:
%w(a span)
)
end
def
image_url
(
source
)
root_url
+
path_to_image
(
source
)
end
alias_method
:url_to_image
,
:image_url
end
app/helpers/projects_helper.rb
View file @
02007866
...
...
@@ -56,7 +56,7 @@ module ProjectsHelper
def
project_title
project
if
project
.
group
content_tag
:span
do
link_to
(
project
.
group
.
name
,
group_path
(
project
.
group
))
+
" / "
+
project
.
name
link_to
(
simple_sanitize
(
project
.
group
.
name
)
,
group_path
(
project
.
group
))
+
" / "
+
project
.
name
end
else
project
.
name
...
...
app/models/namespace.rb
View file @
02007866
...
...
@@ -17,11 +17,15 @@ class Namespace < ActiveRecord::Base
has_many
:projects
,
dependent: :destroy
belongs_to
:owner
,
class_name:
"User"
validates
:name
,
presence:
true
,
uniqueness:
true
validates
:owner
,
presence:
true
validates
:name
,
presence:
true
,
uniqueness:
true
,
length:
{
within:
0
..
255
},
format:
{
with:
Gitlab
::
Regex
.
name_regex
,
message:
"only letters, digits, spaces & '_' '-' '.' allowed."
}
validates
:path
,
uniqueness:
true
,
presence:
true
,
length:
{
within:
1
..
255
},
format:
{
with:
Gitlab
::
Regex
.
path_regex
,
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
validates
:owner
,
presence:
true
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
...
...
app/models/user_team.rb
View file @
02007866
...
...
@@ -21,8 +21,11 @@ class UserTeam < ActiveRecord::Base
has_many
:projects
,
through: :user_team_project_relationships
has_many
:members
,
through: :user_team_user_relationships
,
source: :user
validates
:name
,
presence:
true
,
uniqueness:
true
validates
:owner
,
presence:
true
validates
:name
,
presence:
true
,
uniqueness:
true
,
length:
{
within:
0
..
255
},
format:
{
with:
Gitlab
::
Regex
.
name_regex
,
message:
"only letters, digits, spaces & '_' '-' '.' allowed."
}
validates
:path
,
uniqueness:
true
,
presence:
true
,
length:
{
within:
1
..
255
},
format:
{
with:
Gitlab
::
Regex
.
path_regex
,
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
...
...
lib/gitlab/regex.rb
View file @
02007866
...
...
@@ -10,6 +10,10 @@ module Gitlab
/\A[a-zA-Z][a-zA-Z0-9_\-\. ]*\z/
end
def
name_regex
/\A[a-zA-Z0-9_\-\. ]*\z/
end
def
path_regex
default_regex
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