mirror of
https://github.com/discourse/discourse.git
synced 2025-03-23 08:39:26 +08:00
FIX: Correctly handle the print param on topics#show. (#16555)
The controller incorrectly sets print to true when passing `print=false`, which causes the rate limit to perform.
This commit is contained in:
parent
068e93534c
commit
2a96bca7a1
@ -66,7 +66,7 @@ class TopicsController < ApplicationController
|
||||
opts = params.slice(:username_filters, :filter, :page, :post_number, :show_deleted, :replies_to_post_number, :filter_upwards_post_id, :filter_top_level_replies)
|
||||
username_filters = opts[:username_filters]
|
||||
|
||||
opts[:print] = true if params[:print].present?
|
||||
opts[:print] = true if params[:print] == 'true'
|
||||
opts[:username_filters] = username_filters.split(',') if username_filters.is_a?(String)
|
||||
|
||||
# Special case: a slug with a number in front should look by slug first before looking
|
||||
|
@ -823,7 +823,7 @@ Discourse::Application.routes.draw do
|
||||
# Topic routes
|
||||
get "t/id_for/:slug" => "topics#id_for_slug"
|
||||
get "t/external_id/:external_id" => "topics#show_by_external_id", format: :json, constrains: { external_id: /\A[\w-]+\z/ }
|
||||
get "t/:slug/:topic_id/print" => "topics#show", format: :html, print: true, constraints: { topic_id: /\d+/ }
|
||||
get "t/:slug/:topic_id/print" => "topics#show", format: :html, print: 'true', constraints: { topic_id: /\d+/ }
|
||||
get "t/:slug/:topic_id/wordpress" => "topics#wordpress", constraints: { topic_id: /\d+/ }
|
||||
get "t/:topic_id/wordpress" => "topics#wordpress", constraints: { topic_id: /\d+/ }
|
||||
get "t/:slug/:topic_id/moderator-liked" => "topics#moderator_liked", constraints: { topic_id: /\d+/ }
|
||||
|
@ -2002,6 +2002,13 @@ RSpec.describe TopicsController do
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
|
||||
it "doesn't use print mode when print equals false" do
|
||||
SiteSetting.max_prints_per_hour_per_user = 0
|
||||
|
||||
get "/t/#{topic.slug}/#{topic.id}.json?print=false"
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
context 'a topic with nil slug exists' do
|
||||
before do
|
||||
nil_slug_topic = Fabricate(:topic)
|
||||
|
Loading…
x
Reference in New Issue
Block a user