mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FIX: move crawler blocking into anon cache
This refinement of previous fix moves the crawler blocking into anonymous cache This ensures we never poison the cache incorrectly when blocking crawlers
This commit is contained in:
@ -40,7 +40,6 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
end
|
||||
|
||||
before_action :block_crawlers
|
||||
before_action :check_readonly_mode
|
||||
before_action :handle_theme
|
||||
before_action :set_current_user_for_logs
|
||||
@ -465,19 +464,6 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
private
|
||||
|
||||
def block_crawlers
|
||||
if (
|
||||
request.get? &&
|
||||
!request.xhr? &&
|
||||
!request.path.ends_with?('robots.txt') &&
|
||||
CrawlerDetection.is_blocked_crawler?(request.env['HTTP_USER_AGENT'])
|
||||
)
|
||||
|
||||
request.env["discourse.request_tracker.skip"] = true
|
||||
raise Discourse::InvalidAccess, 'Crawler not allowed'
|
||||
end
|
||||
end
|
||||
|
||||
def check_readonly_mode
|
||||
@readonly_mode = Discourse.readonly_mode?
|
||||
end
|
||||
|
Reference in New Issue
Block a user