mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 05:21:50 +08:00
SECURITY: Prevent ReDoS in user agent parsing (#20002)
Co-authored-by: Penar Musaraj <pmusaraj@gmail.com>
This commit is contained in:
parent
b32db6f2a3
commit
6d92c3cbda
|
@ -36,7 +36,9 @@ module MobileDetection
|
|||
Firefox\/1[0-9][0-9]
|
||||
}x
|
||||
|
||||
USER_AGENT_MAX_LENGTH = 400
|
||||
|
||||
def self.modern_mobile_device?(user_agent)
|
||||
user_agent.match?(MODERN_MOBILE_REGEX)
|
||||
user_agent[0...USER_AGENT_MAX_LENGTH].match?(MODERN_MOBILE_REGEX)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user