Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AO3-6564 Strip images from more fields #4772

Merged
merged 6 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/views/inbox/_inbox_comment_contents.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<% end %>
</div>

<% # This feedback_comment used to be inbox_comment... not sure why %>
<%# This feedback_comment used to be inbox_comment... not sure why %>
brianjaustin marked this conversation as resolved.
Show resolved Hide resolved
<blockquote class="userstuff">
<%= raw sanitize_field(feedback_comment, :comment_content) %>
<%= raw sanitize_field(feedback_comment, :comment_content, strip_images: feedback_comment.ultimate_parent.is_a?(AdminPost)) %>
brianjaustin marked this conversation as resolved.
Show resolved Hide resolved
</blockquote>
4 changes: 2 additions & 2 deletions app/views/user_mailer/abuse_report.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
<p>
<%= style_work_metadata_label(t(".copy.summary")) %>
<% # TODO: Remove to_plain_text when AO3-6519 is fixed. %>
<%= to_plain_text(raw @summary) %>
<%= to_plain_text(raw(strip_images(@summary))) %>
brianjaustin marked this conversation as resolved.
Show resolved Hide resolved
</p>

<p><%= style_work_metadata_label(t(".copy.comment")) %></p>
<p><%= style_quote(raw @comment) %></p>
<p><%= style_quote(raw(strip_images(@comment))) %></p>

<p><%= t(".thank_you") %></p>

Expand Down
4 changes: 2 additions & 2 deletions app/views/user_mailer/abuse_report.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
<%= to_plain_text(@url) %>

<%= work_metadata_label(t(".copy.summary")) %>
<%= to_plain_text(raw @summary) %>
<%= to_plain_text(raw(strip_images(@summary))) %>
brianjaustin marked this conversation as resolved.
Show resolved Hide resolved

<%= work_metadata_label(t(".copy.comment")) %>
<%= to_plain_text(raw @comment) %>
<%= to_plain_text(raw(strip_images(@comment))) %>

<%= text_divider %>

Expand Down
2 changes: 1 addition & 1 deletion app/views/user_mailer/feedback.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
form:
</p>

<%= style_quote("<b>" + (raw @summary) + "</b>" + (raw @comment)) %>
<%= style_quote("<b>#{raw(strip_images(@summary))}</b> #{raw(strip_images(@comment))}") %>

<p>
If you have additional questions or information, do not hesitate to send in
Expand Down
4 changes: 2 additions & 2 deletions app/views/user_mailer/feedback.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ information you submitted through the Technical Support and Feedback form:

<%= text_divider %>

* <%= to_plain_text(raw @summary) %> *
<%= to_plain_text(raw @comment) %>
* <%= to_plain_text(raw(strip_images(@summary))) %> *
<%= to_plain_text(raw(strip_images(@comment))) %>

<%= text_divider %>

Expand Down
12 changes: 12 additions & 0 deletions features/other_a/abuse_report.feature
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,15 @@ Feature: Filing an abuse report
And I press "Submit"
And I should see "Your report was submitted to the Policy & Abuse team. A confirmation message has been sent to the email address you provided."
And 1 email should be delivered

Scenario: File a report containing images

Given I am logged in as "otheruser"
And basic languages
When I follow "Policy Questions & Abuse Reports"
And I fill in "Description of the content you are reporting (required)" with "This is wrong"
And I fill in "Brief summary of Terms of Service violation (required)" with '<img src="foo.jpg" />Hi'
And I fill in "Link to the page you are reporting (required)" with "http://www.archiveofourown.org/works"
And I press "Submit"
Then 1 email should be delivered
And the email should not contain "<img src="foo.jpg" />"
12 changes: 11 additions & 1 deletion features/other_b/support.feature
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,14 @@ Feature: Filing a support request
And I press "Send"
Then I should see "Your message was sent to the Archive team - thank you!"
And 1 email should be delivered


Scenario: Submit a request containing an image

Given I am logged in as "puzzled"
And basic languages
When I follow "Support & Feedback"
And I fill in "Brief summary" with "Just a brief note"
And I fill in "Your question or problem" with '<img src="foo.jpg" />Hi'
And I press "Send"
Then 1 email should be delivered
And the email should not contain "<img src="foo.jpg" />"
12 changes: 12 additions & 0 deletions test/mailers/previews/user_mailer_preview.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
class UserMailerPreview < ApplicationMailerPreview
# Sent to a user when they submit an abuse report
def abuse_report_response
abuse_report = create(:abuse_report)
UserMailer.abuse_report(abuse_report.id)
end

# Sends email when an archivist adds someone as a co-creator.
def creatorship_notification_archivist
second_creatorship, first_creator = creatorship_notification_data
Expand All @@ -17,6 +23,12 @@ def creatorship_request
UserMailer.creatorship_request(second_creatorship.id, first_creator.id)
end

# Sent to a user when the submit a support request (AKA feedback)
def feedback_response
feedback = create(:feedback)
UserMailer.feedback(feedback.id)
end

private

def creatorship_notification_data
Expand Down
Loading