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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
ab5b735b
Commit
ab5b735b
authored
Dec 01, 2020
by
dcouture
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove nested quantifiers from regex
parent
e38dc069
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
1 deletion
+15
-1
app/models/custom_emoji.rb
app/models/custom_emoji.rb
+1
-1
changelogs/unreleased/custom-emoji-name-validation.yml
changelogs/unreleased/custom-emoji-name-validation.yml
+5
-0
spec/models/custom_emoji_spec.rb
spec/models/custom_emoji_spec.rb
+9
-0
No files found.
app/models/custom_emoji.rb
View file @
ab5b735b
...
...
@@ -17,7 +17,7 @@ class CustomEmoji < ApplicationRecord
uniqueness:
{
scope:
[
:namespace_id
,
:name
]
},
presence:
true
,
length:
{
maximum:
36
},
format:
{
with:
/\A
([a-z0-9]+[-_]?)+[a-z0-9]+
\z/
}
format:
{
with:
/\A
[a-z0-9][a-z0-9\-_]*[a-z0-9]
\z/
}
private
...
...
changelogs/unreleased/custom-emoji-name-validation.yml
0 → 100644
View file @
ab5b735b
---
title
:
Fix regular expression backtracking issue in custom emoji name validation
merge_request
:
author
:
type
:
security
spec/models/custom_emoji_spec.rb
View file @
ab5b735b
...
...
@@ -22,6 +22,15 @@ RSpec.describe CustomEmoji do
expect
(
new_emoji
.
errors
.
messages
).
to
eq
(
name:
[
"
#{
emoji_name
}
is already being used for another emoji"
])
end
it
'disallows very long invalid emoji name without regular expression backtracking issues'
do
new_emoji
=
build
(
:custom_emoji
,
name:
'a'
*
10000
+
'!'
,
group:
group
)
Timeout
.
timeout
(
1
)
do
expect
(
new_emoji
).
not_to
be_valid
expect
(
new_emoji
.
errors
.
messages
).
to
eq
(
name:
[
"is too long (maximum is 36 characters)"
,
"is invalid"
])
end
end
it
'disallows duplicate custom emoji names within namespace'
do
old_emoji
=
create
(
:custom_emoji
,
group:
group
)
new_emoji
=
build
(
:custom_emoji
,
name:
old_emoji
.
name
,
namespace:
old_emoji
.
namespace
,
group:
group
)
...
...
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