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
Boxiang Sun
gitlab-ce
Commits
0ebe4191
Commit
0ebe4191
authored
Jan 15, 2019
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `sanitize_name` helper to sanitize URLs in user full name
parent
7a10ef6e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
app/helpers/emails_helper.rb
app/helpers/emails_helper.rb
+8
-0
spec/helpers/emails_helper_spec.rb
spec/helpers/emails_helper_spec.rb
+14
-0
No files found.
app/helpers/emails_helper.rb
View file @
0ebe4191
...
@@ -36,6 +36,14 @@ module EmailsHelper
...
@@ -36,6 +36,14 @@ module EmailsHelper
nil
nil
end
end
def
sanitize_name
(
name
)
if
name
=~
URI
::
DEFAULT_PARSER
.
regexp
[
:URI_REF
]
name
.
tr
(
'.'
,
'_'
)
else
name
end
end
def
password_reset_token_valid_time
def
password_reset_token_valid_time
valid_hours
=
Devise
.
reset_password_within
/
60
/
60
valid_hours
=
Devise
.
reset_password_within
/
60
/
60
if
valid_hours
>=
24
if
valid_hours
>=
24
...
...
spec/helpers/emails_helper_spec.rb
View file @
0ebe4191
require
'spec_helper'
require
'spec_helper'
describe
EmailsHelper
do
describe
EmailsHelper
do
describe
'sanitize_name'
do
context
'when name contains a valid URL string'
do
it
'returns name with `.` replaced with `_` to prevent mail clients from auto-linking URLs'
do
expect
(
sanitize_name
(
'https://about.gitlab.com'
)).
to
eq
(
'https://about_gitlab_com'
)
expect
(
sanitize_name
(
'www.gitlab.com'
)).
to
eq
(
'www_gitlab_com'
)
expect
(
sanitize_name
(
'//about.gitlab.com/handbook/security/#best-practices'
)).
to
eq
(
'//about_gitlab_com/handbook/security/#best-practices'
)
end
it
'returns name as it is when it does not contain a URL'
do
expect
(
sanitize_name
(
'Foo Bar'
)).
to
eq
(
'Foo Bar'
)
end
end
end
describe
'password_reset_token_valid_time'
do
describe
'password_reset_token_valid_time'
do
def
validate_time_string
(
time_limit
,
expected_string
)
def
validate_time_string
(
time_limit
,
expected_string
)
Devise
.
reset_password_within
=
time_limit
Devise
.
reset_password_within
=
time_limit
...
...
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