FEATURE: Implement browser update in crawler view (#12448)

browser-update script does not work correctly in some very old browsers
because the contents of <noscript> is not accessible in JavaScript.
For these browsers, the server can display the crawler page and add the
browser update notice.

Simply loading the browser-update script in the crawler view is not a
solution because that means all crawlers will also see it.
This commit is contained in:
Dan Ungureanu
2021-03-22 19:41:42 +02:00
committed by GitHub
parent 3e586ab25a
commit 4e46732346
5 changed files with 41 additions and 2 deletions

View File

@ -37,6 +37,14 @@ module CrawlerDetection
end
def self.show_browser_update?(user_agent)
return false if SiteSetting.browser_update_user_agents.blank?
@browser_update_matchers ||= {}
matcher = @browser_update_matchers[SiteSetting.browser_update_user_agents] ||= to_matcher(SiteSetting.browser_update_user_agents)
user_agent.match?(matcher)
end
# Given a user_agent that returns true from crawler?, should its request be allowed?
def self.allow_crawler?(user_agent)
return true if SiteSetting.allowed_crawler_user_agents.blank? &&