mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 08:49:06 +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]
|
Firefox\/1[0-9][0-9]
|
||||||
}x
|
}x
|
||||||
|
|
||||||
|
USER_AGENT_MAX_LENGTH = 400
|
||||||
|
|
||||||
def self.modern_mobile_device?(user_agent)
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user