From: Tom Hughes Date: Sun, 5 Jan 2025 16:14:18 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/pull/5469' X-Git-Tag: live~657 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/3faf9a77f7e4fa9e162e02922c0dd166b0362ddd?hp=af9d4f26962f7cdf30eef6bdfe53034df55598e4 Merge remote-tracking branch 'upstream/pull/5469' --- diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 32b53bad7..1ef49bf46 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/app/controllers/diary_comments_controller.rb b/app/controllers/diary_comments_controller.rb index f6597cf4c..676bc22a6 100644 --- a/app/controllers/diary_comments_controller.rb +++ b/app/controllers/diary_comments_controller.rb @@ -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 diff --git a/test/controllers/diary_comments_controller_test.rb b/test/controllers/diary_comments_controller_test.rb index 65a71a9b5..3ea9bc094 100644 --- a/test/controllers/diary_comments_controller_test.rb +++ b/test/controllers/diary_comments_controller_test.rb @@ -104,6 +104,7 @@ class DiaryCommentsControllerTest < ActionDispatch::IntegrationTest 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 diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index ba1af9509..7b554711f 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -57,6 +57,8 @@ class UsersControllerTest < ActionDispatch::IntegrationTest 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 @@ -297,6 +299,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest 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