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
b2946af5
Commit
b2946af5
authored
Mar 20, 2020
by
nicolasdular
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use existing regexp validator
parent
7e3afaaa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
2 additions
and
13 deletions
+2
-13
app/models/application_setting.rb
app/models/application_setting.rb
+1
-9
app/validators/untrusted_regexp_validator.rb
app/validators/untrusted_regexp_validator.rb
+0
-0
locale/gitlab.pot
locale/gitlab.pot
+0
-3
spec/models/application_setting_spec.rb
spec/models/application_setting_spec.rb
+1
-1
No files found.
app/models/application_setting.rb
View file @
b2946af5
...
...
@@ -257,7 +257,7 @@ class ApplicationSetting < ApplicationRecord
validates
:snippet_size_limit
,
numericality:
{
only_integer:
true
,
greater_than:
0
}
validate
:email_restrictions_regex_valid?
validate
s
:email_restrictions
,
untrusted_regexp:
true
SUPPORTED_KEY_TYPES
.
each
do
|
type
|
validates
:"
#{
type
}
_key_restriction"
,
presence:
true
,
key_restriction:
{
type:
type
}
...
...
@@ -411,14 +411,6 @@ class ApplicationSetting < ApplicationRecord
recaptcha_enabled
||
login_recaptcha_protection_enabled
end
def
email_restrictions_regex_valid?
return
if
email_restrictions
.
blank?
Gitlab
::
UntrustedRegexp
.
new
(
email_restrictions
)
rescue
RegexpError
errors
.
add
(
:email_restrictions
,
_
(
'is not a valid regular expression'
))
end
private
def
parsed_grafana_url
...
...
ee/
app/validators/untrusted_regexp_validator.rb
→
app/validators/untrusted_regexp_validator.rb
View file @
b2946af5
File moved
locale/gitlab.pot
View file @
b2946af5
...
...
@@ -23945,9 +23945,6 @@ msgstr ""
msgid "is not a valid X509 certificate."
msgstr ""
msgid "is not a valid regular expression"
msgstr ""
msgid "is not allowed for sign-up"
msgstr ""
...
...
spec/models/application_setting_spec.rb
View file @
b2946af5
...
...
@@ -715,7 +715,7 @@ describe ApplicationSetting do
subject
.
email_restrictions
=
'+'
expect
(
subject
).
not_to
be_valid
expect
(
subject
.
errors
.
messages
[
:email_restrictions
].
first
).
to
eq
(
_
(
'
is not a valid regular expression
'
))
expect
(
subject
.
errors
.
messages
[
:email_restrictions
].
first
).
to
eq
(
_
(
'
not valid RE2 syntax: no argument for repetition operator: +
'
))
end
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