mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
SECURITY: Ensure user-agent-based responses are cached separately (#16475)
This commit is contained in:
@ -12,6 +12,8 @@ module Middleware
|
||||
@@cache_key_segments ||= {
|
||||
m: 'key_is_mobile?',
|
||||
c: 'key_is_crawler?',
|
||||
o: 'key_is_old_browser?',
|
||||
d: 'key_is_modern_mobile_device?',
|
||||
b: 'key_has_brotli?',
|
||||
t: 'key_cache_theme_ids',
|
||||
ca: 'key_compress_anon',
|
||||
@ -120,6 +122,14 @@ module Middleware
|
||||
end
|
||||
alias_method :key_is_crawler?, :is_crawler?
|
||||
|
||||
def key_is_modern_mobile_device?
|
||||
MobileDetection.modern_mobile_device?(@env[USER_AGENT]) if @env[USER_AGENT]
|
||||
end
|
||||
|
||||
def key_is_old_browser?
|
||||
CrawlerDetection.show_browser_update?(@env[USER_AGENT]) if @env[USER_AGENT]
|
||||
end
|
||||
|
||||
def cache_key
|
||||
return @cache_key if defined?(@cache_key)
|
||||
|
||||
|
Reference in New Issue
Block a user