Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/pull/5469'
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Jan 5, 2025
2 parents af9d4f2 + 11b887c commit 3faf9a7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ApplicationController < ActionController::Base
helper_method :oauth_token

def self.allow_thirdparty_images(**options)
content_security_policy(options) do |policy|
content_security_policy(**options) do |policy|
policy.img_src("*", :data)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/diary_comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DiaryCommentsController < ApplicationController
before_action :lookup_user, :only => :index
before_action :check_database_writable, :only => [:create, :hide, :unhide]

allow_thirdparty_images :only => :index
allow_thirdparty_images :only => [:index, :create]

def index
@title = t ".title", :user => @user.display_name
Expand Down
1 change: 1 addition & 0 deletions test/controllers/diary_comments_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def test_create
end
assert_response :success
assert_template :new
assert_match(/img-src \* data:;/, @response.headers["Content-Security-Policy-Report-Only"])

# Now try again with the right id
assert_difference "ActionMailer::Base.deliveries.size", entry.subscribers.count do
Expand Down
3 changes: 3 additions & 0 deletions test/controllers/users_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def test_new_view
get user_new_path, :params => { :cookie_test => "true" }
assert_response :success

assert_no_match(/img-src \* data:;/, @response.headers["Content-Security-Policy-Report-Only"])

assert_select "html", :count => 1 do
assert_select "head", :count => 1 do
assert_select "title", :text => /Sign Up/, :count => 1
Expand Down Expand Up @@ -297,6 +299,7 @@ def test_show

get user_path(user)
assert_response :success
assert_match(/img-src \* data:;/, @response.headers["Content-Security-Policy-Report-Only"])
assert_select "div.content-heading" do
assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1
assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/traces']", 1
Expand Down

0 comments on commit 3faf9a7

Please sign in to comment.