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
15490396
Commit
15490396
authored
Jan 15, 2019
by
Kushal Pandya
Committed by
Yorick Peterse
Jan 31, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `sanitize_name` helper to sanitize URLs in user full name
parent
b026db4d
Changes
2
Hide 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 @
15490396
...
...
@@ -36,6 +36,14 @@ module EmailsHelper
nil
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
valid_hours
=
Devise
.
reset_password_within
/
60
/
60
if
valid_hours
>=
24
...
...
spec/helpers/emails_helper_spec.rb
View file @
15490396
require
'spec_helper'
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
def
validate_time_string
(
time_limit
,
expected_string
)
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