From 9c48813d814e6d0a8070c669d4d288eeb070b929 Mon Sep 17 00:00:00 2001 From: Holger Just Date: Tue, 2 Jan 2024 21:51:30 +0100 Subject: [PATCH] Explicitly render a 404 on non-JS requests to @messages#new@ --- app/controllers/messages_controller.rb | 5 +++++ test/functional/messages_controller_test.rb | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index b41830b852..a4b4478a23 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -125,6 +125,11 @@ def quote @content = +"#{ll(Setting.default_language, :text_user_wrote_in, {:value => @message.author, :link => "message##{@message.id}"})}\n> " end @content << @message.content.to_s.strip.gsub(%r{
(.*?)
}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" + + respond_to do |format| + format.html { render_404 } + format.js + end end def preview diff --git a/test/functional/messages_controller_test.rb b/test/functional/messages_controller_test.rb index 2535e570b8..4e146e4e6e 100644 --- a/test/functional/messages_controller_test.rb +++ b/test/functional/messages_controller_test.rb @@ -311,6 +311,19 @@ def test_quote_if_message_is_not_root assert_include '> An other reply', response.body end + def test_quote_as_html_should_respond_with_404 + @request.session[:user_id] = 2 + get( + :quote, + :params => { + :board_id => 1, + :id => 3 + }, + ) + + assert_response 404 + end + def test_preview_new @request.session[:user_id] = 2 post( -- 2.39.2