Commit 08c1989b authored by Kushal Pandya's avatar Kushal Pandya Committed by Yorick Peterse

Use `sanitize_name` to sanitize URL in user full name

parent 35b8f103
#content #content
= email_default_heading("#{@resource.user.name}, you've added an additional email!") = email_default_heading("#{sanitize_name(@resource.user.name)}, you've added an additional email!")
%p Click the link below to confirm your email address (#{@resource.email}) %p Click the link below to confirm your email address (#{@resource.email})
#cta #cta
= link_to 'Confirm your email address', confirmation_url(@resource, confirmation_token: @token) = link_to 'Confirm your email address', confirmation_url(@resource, confirmation_token: @token)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<% discussion = note.discussion if note.part_of_discussion? -%> <% discussion = note.discussion if note.part_of_discussion? -%>
<% if discussion && !discussion.individual_note? -%> <% if discussion && !discussion.individual_note? -%>
<%= note.author_name -%> <%= sanitize_name(note.author_name) -%>
<% if discussion.new_discussion? -%> <% if discussion.new_discussion? -%>
<%= " started a new discussion" -%> <%= " started a new discussion" -%>
<% else -%> <% else -%>
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<% elsif Gitlab::CurrentSettings.email_author_in_body -%> <% elsif Gitlab::CurrentSettings.email_author_in_body -%>
<%= "#{note.author_name} commented:" -%> <%= "#{sanitize_name(note.author_name)} commented:" -%>
<% end -%> <% end -%>
......
...@@ -3,7 +3,7 @@ Auto DevOps pipeline was disabled for <%= @project.name %> ...@@ -3,7 +3,7 @@ Auto DevOps pipeline was disabled for <%= @project.name %>
The Auto DevOps pipeline failed for pipeline <%= @pipeline.iid %> (<%= pipeline_url(@pipeline) %>) and has been disabled for <%= @project.name %>. In order to use the Auto DevOps pipeline with your project, please review the currently supported languagues (https://docs.gitlab.com/ee/topics/autodevops/#currently-supported-languages), adjust your project accordingly, and turn on the Auto DevOps pipeline within your CI/CD project settings (<%= project_settings_ci_cd_url(@project) %>). The Auto DevOps pipeline failed for pipeline <%= @pipeline.iid %> (<%= pipeline_url(@pipeline) %>) and has been disabled for <%= @project.name %>. In order to use the Auto DevOps pipeline with your project, please review the currently supported languagues (https://docs.gitlab.com/ee/topics/autodevops/#currently-supported-languages), adjust your project accordingly, and turn on the Auto DevOps pipeline within your CI/CD project settings (<%= project_settings_ci_cd_url(@project) %>).
<% if @pipeline.user -%> <% if @pipeline.user -%>
Pipeline #<%= @pipeline.id %> ( <%= pipeline_url(@pipeline) %> ) triggered by <%= @pipeline.user.name %> ( <%= user_url(@pipeline.user) %> ) Pipeline #<%= @pipeline.id %> ( <%= pipeline_url(@pipeline) %> ) triggered by <%= sanitize_name(@pipeline.user.name) %> ( <%= user_url(@pipeline.user) %> )
<% else -%> <% else -%>
Pipeline #<%= @pipeline.id %> ( <%= pipeline_url(@pipeline) %> ) triggered by API Pipeline #<%= @pipeline.id %> ( <%= pipeline_url(@pipeline) %> ) triggered by API
<% end -%> <% end -%>
......
%p %p
Issue was closed by #{@updated_by.name} Issue was closed by #{sanitize_name(@updated_by.name)}
Issue was closed by #{@updated_by.name} Issue was closed by #{sanitize_name(@updated_by.name)}
Issue ##{@issue.iid}: #{project_issue_url(@issue.project, @issue)} Issue ##{@issue.iid}: #{project_issue_url(@issue.project, @issue)}
%p %p
Merge Request #{@merge_request.to_reference} was closed by #{@updated_by.name} Merge Request #{@merge_request.to_reference} was closed by #{sanitize_name(@updated_by.name)}
Merge Request #{@merge_request.to_reference} was closed by #{@updated_by.name} Merge Request #{@merge_request.to_reference} was closed by #{sanitize_name(@updated_by.name)}
Merge Request url: #{project_merge_request_url(@merge_request.target_project, @merge_request)} Merge Request url: #{project_merge_request_url(@merge_request.target_project, @merge_request)}
= merge_path_description(@merge_request, 'to') = merge_path_description(@merge_request, 'to')
Author: #{@merge_request.author_name} Author: #{sanitize_name(@merge_request.author_name)}
Assignee: #{@merge_request.assignee_name} Assignee: #{sanitize_name(@merge_request.assignee_name)}
%p %p
Issue was #{@issue_status} by #{@updated_by.name} Issue was #{@issue_status} by #{sanitize_name(@updated_by.name)}
Issue was <%= @issue_status %> by <%= @updated_by.name %> Issue was <%= @issue_status %> by <%= sanitize_name(@updated_by.name) %>
Issue <%= @issue.iid %>: <%= url_for(project_issue_url(@issue.project, @issue)) %> Issue <%= @issue.iid %>: <%= url_for(project_issue_url(@issue.project, @issue)) %>
<%= member.user.name %> (<%= user_url(member.user) %>) requested <%= member.human_access %> access to the <%= member_source.human_name %> <%= member_source.model_name.singular %>. <%= sanitize_name(member.user.name) %> (<%= user_url(member.user) %>) requested <%= member.human_access %> access to the <%= member_source.human_name %> <%= member_source.model_name.singular %>.
<%= polymorphic_url([member_source, :members]) %> <%= polymorphic_url([member_source, :members]) %>
<%= member.invite_email %>, now known as <%= member.user.name %>, has accepted your invitation to join the <%= member_source.human_name %> <%= member_source.model_name.singular %>. <%= member.invite_email %>, now known as <%= sanitize_name(member.user.name) %>, has accepted your invitation to join the <%= member_source.human_name %> <%= member_source.model_name.singular %>.
<%= member_source.web_url %> <%= member_source.web_url %>
You have been invited <%= "by #{member.created_by.name} " if member.created_by %>to join the <%= member_source.human_name %> <%= member_source.model_name.singular %> as <%= member.human_access %>. You have been invited <%= "by #{sanitize_name(member.created_by.name)} " if member.created_by %>to join the <%= member_source.human_name %> <%= member_source.model_name.singular %> as <%= member.human_access %>.
Accept invitation: <%= invite_url(@token) %> Accept invitation: <%= invite_url(@token) %>
Decline invitation: <%= decline_invite_url(@token) %> Decline invitation: <%= decline_invite_url(@token) %>
%p %p
Merge Request #{@merge_request.to_reference} was #{@mr_status} by #{@updated_by.name} Merge Request #{@merge_request.to_reference} was #{@mr_status} by #{sanitize_name(@updated_by.name)}
Merge Request #{@merge_request.to_reference} was #{@mr_status} by #{@updated_by.name} Merge Request #{@merge_request.to_reference} was #{@mr_status} by #{sanitize_name(@updated_by.name)}
Merge Request url: #{project_merge_request_url(@merge_request.target_project, @merge_request)} Merge Request url: #{project_merge_request_url(@merge_request.target_project, @merge_request)}
= merge_path_description(@merge_request, 'to') = merge_path_description(@merge_request, 'to')
Author: #{@merge_request.author_name} Author: #{sanitize_name(@merge_request.author_name)}
Assignee: #{@merge_request.assignee_name} Assignee: #{sanitize_name(@merge_request.assignee_name)}
...@@ -4,5 +4,5 @@ Merge Request url: #{project_merge_request_url(@merge_request.target_project, @m ...@@ -4,5 +4,5 @@ Merge Request url: #{project_merge_request_url(@merge_request.target_project, @m
= merge_path_description(@merge_request, 'to') = merge_path_description(@merge_request, 'to')
Author: #{@merge_request.author_name} Author: #{sanitize_name(@merge_request.author_name)}
Assignee: #{@merge_request.assignee_name} Assignee: #{sanitize_name(@merge_request.assignee_name)}
...@@ -4,5 +4,5 @@ Merge Request url: #{project_merge_request_url(@merge_request.target_project, @m ...@@ -4,5 +4,5 @@ Merge Request url: #{project_merge_request_url(@merge_request.target_project, @m
= merge_path_description(@merge_request, 'to') = merge_path_description(@merge_request, 'to')
Author: #{@merge_request.author_name} Author: #{sanitize_name(@merge_request.author_name)}
Assignee: #{@merge_request.assignee_name} Assignee: #{sanitize_name(@merge_request.assignee_name)}
%p %p
Hi #{@user.name}! Hi #{sanitize_name(@user.name)}!
%p %p
A new GPG key was added to your account: A new GPG key was added to your account:
%p %p
......
Hi <%= @user.name %>! Hi <%= sanitize_name(@user.name) %>!
A new GPG key was added to your account: A new GPG key was added to your account:
......
New Issue was created. New Issue was created.
Issue <%= @issue.iid %>: <%= url_for(project_issue_url(@issue.project, @issue)) %> Issue <%= @issue.iid %>: <%= url_for(project_issue_url(@issue.project, @issue)) %>
Author: <%= @issue.author_name %> Author: <%= sanitize_name(@issue.author_name) %>
Assignee: <%= @issue.assignee_list %> Assignee: <%= @issue.assignee_list %>
<%= @issue.description %> <%= @issue.description %>
You have been mentioned in an issue. You have been mentioned in an issue.
Issue <%= @issue.iid %>: <%= url_for(project_issue_url(@issue.project, @issue)) %> Issue <%= @issue.iid %>: <%= url_for(project_issue_url(@issue.project, @issue)) %>
Author: <%= @issue.author_name %> Author: <%= sanitize_name(@issue.author_name) %>
Assignee: <%= @issue.assignee_list %> Assignee: <%= sanitize_name(@issue.assignee_list) %>
<%= @issue.description %> <%= @issue.description %>
...@@ -3,7 +3,7 @@ You have been mentioned in Merge Request <%= @merge_request.to_reference %> ...@@ -3,7 +3,7 @@ You have been mentioned in Merge Request <%= @merge_request.to_reference %>
<%= url_for(project_merge_request_url(@merge_request.target_project, @merge_request)) %> <%= url_for(project_merge_request_url(@merge_request.target_project, @merge_request)) %>
<%= merge_path_description(@merge_request, 'to') %> <%= merge_path_description(@merge_request, 'to') %>
Author: <%= @merge_request.author_name %> Author: <%= sanitize_name(@merge_request.author_name) %>
Assignee: <%= @merge_request.assignee_name %> Assignee: <%= sanitize_name(@merge_request.assignee_name) %>
<%= @merge_request.description %> <%= @merge_request.description %>
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
- if @merge_request.assignee_id.present? - if @merge_request.assignee_id.present?
%p %p
Assignee: #{@merge_request.assignee_name} Assignee: #{sanitize_name(@merge_request.assignee_name)}
= render_if_exists 'notify/merge_request_approvers', presenter: @mr_presenter = render_if_exists 'notify/merge_request_approvers', presenter: @mr_presenter
......
%p %p
Hi #{@user.name}! Hi #{sanitize_name(@user.name)}!
%p %p
A new public key was added to your account: A new public key was added to your account:
%p %p
......
Hi <%= @user.name %>! Hi <%= sanitize_name(@user.name) %>!
A new public key was added to your account: A new public key was added to your account:
......
%p %p
Hi #{@user['name']}! Hi #{sanitize_name(@user['name'])}!
%p %p
- if Gitlab::CurrentSettings.allow_signup? - if Gitlab::CurrentSettings.allow_signup?
Your account has been created successfully. Your account has been created successfully.
......
Hi <%= @user.name %>! Hi <%= sanitize_name(@user.name) %>!
The Administrator created an account for you. Now you are a member of the company GitLab application. The Administrator created an account for you. Now you are a member of the company GitLab application.
......
...@@ -10,20 +10,20 @@ Commit: <%= @pipeline.short_sha %> ( <%= commit_url(@pipeline) %> ) ...@@ -10,20 +10,20 @@ Commit: <%= @pipeline.short_sha %> ( <%= commit_url(@pipeline) %> )
Commit Message: <%= @pipeline.git_commit_message.truncate(50) %> Commit Message: <%= @pipeline.git_commit_message.truncate(50) %>
<% commit = @pipeline.commit -%> <% commit = @pipeline.commit -%>
<% if commit.author -%> <% if commit.author -%>
Commit Author: <%= commit.author.name %> ( <%= user_url(commit.author) %> ) Commit Author: <%= sanitize_name(commit.author.name) %> ( <%= user_url(commit.author) %> )
<% else -%> <% else -%>
Commit Author: <%= commit.author_name %> Commit Author: <%= commit.author_name %>
<% end -%> <% end -%>
<% if commit.different_committer? -%> <% if commit.different_committer? -%>
<% if commit.committer -%> <% if commit.committer -%>
Committed by: <%= commit.committer.name %> ( <%= user_url(commit.committer) %> ) Committed by: <%= sanitize_name(commit.committer.name) %> ( <%= user_url(commit.committer) %> )
<% else -%> <% else -%>
Committed by: <%= commit.committer_name %> Committed by: <%= commit.committer_name %>
<% end -%> <% end -%>
<% end -%> <% end -%>
<% if @pipeline.user -%> <% if @pipeline.user -%>
Pipeline #<%= @pipeline.id %> ( <%= pipeline_url(@pipeline) %> ) triggered by <%= @pipeline.user.name %> ( <%= user_url(@pipeline.user) %> ) Pipeline #<%= @pipeline.id %> ( <%= pipeline_url(@pipeline) %> ) triggered by <%= sanitize_name(@pipeline.user.name) %> ( <%= user_url(@pipeline.user) %> )
<% else -%> <% else -%>
Pipeline #<%= @pipeline.id %> ( <%= pipeline_url(@pipeline) %> ) triggered by API Pipeline #<%= @pipeline.id %> ( <%= pipeline_url(@pipeline) %> ) triggered by API
<% end -%> <% end -%>
......
...@@ -10,13 +10,13 @@ Commit: <%= @pipeline.short_sha %> ( <%= commit_url(@pipeline) %> ) ...@@ -10,13 +10,13 @@ Commit: <%= @pipeline.short_sha %> ( <%= commit_url(@pipeline) %> )
Commit Message: <%= @pipeline.git_commit_message.truncate(50) %> Commit Message: <%= @pipeline.git_commit_message.truncate(50) %>
<% commit = @pipeline.commit -%> <% commit = @pipeline.commit -%>
<% if commit.author -%> <% if commit.author -%>
Commit Author: <%= commit.author.name %> ( <%= user_url(commit.author) %> ) Commit Author: <%= sanitize_name(commit.author.name) %> ( <%= user_url(commit.author) %> )
<% else -%> <% else -%>
Commit Author: <%= commit.author_name %> Commit Author: <%= commit.author_name %>
<% end -%> <% end -%>
<% if commit.different_committer? -%> <% if commit.different_committer? -%>
<% if commit.committer -%> <% if commit.committer -%>
Committed by: <%= commit.committer.name %> ( <%= user_url(commit.committer) %> ) Committed by: <%= sanitize_name(commit.committer.name) %> ( <%= user_url(commit.committer) %> )
<% else -%> <% else -%>
Committed by: <%= commit.committer_name %> Committed by: <%= commit.committer_name %>
<% end -%> <% end -%>
...@@ -25,7 +25,7 @@ Committed by: <%= commit.committer_name %> ...@@ -25,7 +25,7 @@ Committed by: <%= commit.committer_name %>
<% job_count = @pipeline.total_size -%> <% job_count = @pipeline.total_size -%>
<% stage_count = @pipeline.stages_count -%> <% stage_count = @pipeline.stages_count -%>
<% if @pipeline.user -%> <% if @pipeline.user -%>
Pipeline #<%= @pipeline.id %> ( <%= pipeline_url(@pipeline) %> ) triggered by <%= @pipeline.user.name %> ( <%= user_url(@pipeline.user) %> ) Pipeline #<%= @pipeline.id %> ( <%= pipeline_url(@pipeline) %> ) triggered by <%= sanitize_name(@pipeline.user.name) %> ( <%= user_url(@pipeline.user) %> )
<% else -%> <% else -%>
Pipeline #<%= @pipeline.id %> ( <%= pipeline_url(@pipeline) %> ) triggered by API Pipeline #<%= @pipeline.id %> ( <%= pipeline_url(@pipeline) %> ) triggered by API
<% end -%> <% end -%>
......
%h3 %h3
= @updated_by_user.name = sanitize_name(@updated_by_user.name)
pushed new commits to merge request pushed new commits to merge request
= link_to(@merge_request.to_reference, project_merge_request_url(@merge_request.target_project, @merge_request)) = link_to(@merge_request.to_reference, project_merge_request_url(@merge_request.target_project, @merge_request))
......
#{@updated_by_user.name} pushed new commits to merge request #{@merge_request.to_reference} #{sanitize_name(@updated_by_user.name)} pushed new commits to merge request #{@merge_request.to_reference}
\ \
#{url_for(project_merge_request_url(@merge_request.target_project, @merge_request))} #{url_for(project_merge_request_url(@merge_request.target_project, @merge_request))}
\ \
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Assignee changed Assignee changed
- if @previous_assignees.any? - if @previous_assignees.any?
from from
%strong= @previous_assignees.map(&:name).to_sentence %strong= sanitize_name(@previous_assignees.map(&:name).to_sentence)
to to
- if @issue.assignees.any? - if @issue.assignees.any?
%strong= @issue.assignee_list %strong= @issue.assignee_list
......
...@@ -2,5 +2,5 @@ Reassigned Issue <%= @issue.iid %> ...@@ -2,5 +2,5 @@ Reassigned Issue <%= @issue.iid %>
<%= url_for([@issue.project.namespace.becomes(Namespace), @issue.project, @issue, { only_path: false }]) %> <%= url_for([@issue.project.namespace.becomes(Namespace), @issue.project, @issue, { only_path: false }]) %>
Assignee changed <%= "from #{@previous_assignees.map(&:name).to_sentence}" if @previous_assignees.any? -%> Assignee changed <%= "from #{sanitize_name(@previous_assignees.map(&:name).to_sentence)}" if @previous_assignees.any? -%>
to <%= "#{@issue.assignees.any? ? @issue.assignee_list : 'Unassigned'}" %> to <%= "#{@issue.assignees.any? ? @issue.assignee_list : 'Unassigned'}" %>
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
Assignee changed Assignee changed
- if @previous_assignee - if @previous_assignee
from from
%strong= @previous_assignee.name %strong= sanitize_name(@previous_assignee.name)
to to
- if @merge_request.assignee_id - if @merge_request.assignee_id
%strong= @merge_request.assignee_name %strong= sanitize_name(@merge_request.assignee_name)
- else - else
%strong Unassigned %strong Unassigned
...@@ -2,5 +2,5 @@ Reassigned Merge Request <%= @merge_request.iid %> ...@@ -2,5 +2,5 @@ Reassigned Merge Request <%= @merge_request.iid %>
<%= url_for([@merge_request.project.namespace.becomes(Namespace), @merge_request.project, @merge_request, { only_path: false }]) %> <%= url_for([@merge_request.project.namespace.becomes(Namespace), @merge_request.project, @merge_request, { only_path: false }]) %>
Assignee changed <%= "from #{@previous_assignee.name}" if @previous_assignee -%> Assignee changed <%= "from #{sanitize_name(@previous_assignee.name)}" if @previous_assignee -%>
to <%= "#{@merge_request.assignee_id ? @merge_request.assignee_name : 'Unassigned'}" %> to <%= "#{@merge_request.assignee_id ? sanitize_name(@merge_request.assignee_name) : 'Unassigned'}" %>
%p %p
All discussions on Merge Request #{@merge_request.to_reference} were resolved by #{@resolved_by.name} All discussions on Merge Request #{@merge_request.to_reference} were resolved by #{sanitize_name(@resolved_by.name)}
All discussions on Merge Request <%= @merge_request.to_reference %> were resolved by <%= @resolved_by.name %> All discussions on Merge Request <%= @merge_request.to_reference %> were resolved by <%= sanitize_name(@resolved_by.name) %>
<%= url_for(project_merge_request_url(@merge_request.target_project, @merge_request)) %> <%= url_for(project_merge_request_url(@merge_request.target_project, @merge_request)) %>
...@@ -9,8 +9,10 @@ describe Notify do ...@@ -9,8 +9,10 @@ describe Notify do
include_context 'gitlab email notification' include_context 'gitlab email notification'
let(:current_user_sanitized) { 'www_example_com' }
set(:user) { create(:user) } set(:user) { create(:user) }
set(:current_user) { create(:user, email: "current@email.com") } set(:current_user) { create(:user, email: "current@email.com", name: 'www.example.com') }
set(:assignee) { create(:user, email: 'assignee@example.com', name: 'John Doe') } set(:assignee) { create(:user, email: 'assignee@example.com', name: 'John Doe') }
set(:merge_request) do set(:merge_request) do
...@@ -182,7 +184,7 @@ describe Notify do ...@@ -182,7 +184,7 @@ describe Notify do
aggregate_failures do aggregate_failures do
is_expected.to have_referable_subject(issue, reply: true) is_expected.to have_referable_subject(issue, reply: true)
is_expected.to have_body_text(status) is_expected.to have_body_text(status)
is_expected.to have_body_text(current_user.name) is_expected.to have_body_text(current_user_sanitized)
is_expected.to have_body_text(project_issue_path project, issue) is_expected.to have_body_text(project_issue_path project, issue)
end end
end end
...@@ -361,7 +363,7 @@ describe Notify do ...@@ -361,7 +363,7 @@ describe Notify do
aggregate_failures do aggregate_failures do
is_expected.to have_referable_subject(merge_request, reply: true) is_expected.to have_referable_subject(merge_request, reply: true)
is_expected.to have_body_text(status) is_expected.to have_body_text(status)
is_expected.to have_body_text(current_user.name) is_expected.to have_body_text(current_user_sanitized)
is_expected.to have_body_text(project_merge_request_path(project, merge_request)) is_expected.to have_body_text(project_merge_request_path(project, merge_request))
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment