Add CPU type filter

This commit is contained in:
Brendan Coles
2014-04-25 04:16:53 +10:00
parent a317b223ca
commit 9af8e6bd00

View File

@@ -12,7 +12,7 @@ module Filters
def self.is_valid_browsername?(str) def self.is_valid_browsername?(str)
return false if not is_non_empty_string?(str) return false if not is_non_empty_string?(str)
return false if str.length > 2 return false if str.length > 2
return false if has_non_printable_char?(str) return false if has_non_printable_char?(str)
true true
end end
@@ -32,7 +32,7 @@ module Filters
# @return [Boolean] If the string has valid Operating System name characters # @return [Boolean] If the string has valid Operating System name characters
def self.is_valid_osname?(str) def self.is_valid_osname?(str)
return false if not is_non_empty_string?(str) return false if not is_non_empty_string?(str)
return false if has_non_printable_char?(str) return false if has_non_printable_char?(str)
return false if str.length < 2 return false if str.length < 2
true true
end end
@@ -52,7 +52,7 @@ module Filters
# @return [Boolean] If the string has valid browser version characters # @return [Boolean] If the string has valid browser version characters
def self.is_valid_browserversion?(str) def self.is_valid_browserversion?(str)
return false if not is_non_empty_string?(str) return false if not is_non_empty_string?(str)
return false if has_non_printable_char?(str) return false if has_non_printable_char?(str)
return true if str.eql? "UNKNOWN" return true if str.eql? "UNKNOWN"
return false if not nums_only?(str) and not is_valid_float?(str) return false if not nums_only?(str) and not is_valid_float?(str)
return false if str.length > 10 return false if str.length > 10
@@ -64,7 +64,7 @@ module Filters
# @return [Boolean] If the string has valid browser / ua string characters # @return [Boolean] If the string has valid browser / ua string characters
def self.is_valid_browserstring?(str) def self.is_valid_browserstring?(str)
return false if not is_non_empty_string?(str) return false if not is_non_empty_string?(str)
return false if has_non_printable_char?(str) return false if has_non_printable_char?(str)
return false if str.length > 300 return false if str.length > 300
true true
end end
@@ -73,7 +73,7 @@ module Filters
# @param [String] str String for testing # @param [String] str String for testing
# @return [Boolean] If the string has valid cookie characters # @return [Boolean] If the string has valid cookie characters
def self.is_valid_cookies?(str) def self.is_valid_cookies?(str)
return false if has_non_printable_char?(str) return false if has_non_printable_char?(str)
return false if str.length > 2000 return false if str.length > 2000
true true
end end
@@ -82,7 +82,7 @@ module Filters
# @param [String] str String for testing # @param [String] str String for testing
# @return [Boolean] If the string has valid screen size characters # @return [Boolean] If the string has valid screen size characters
def self.is_valid_screen_size?(str) def self.is_valid_screen_size?(str)
return false if has_non_printable_char?(str) return false if has_non_printable_char?(str)
return false if str.length > 200 return false if str.length > 200
true true
end end
@@ -91,7 +91,7 @@ module Filters
# @param [String] str String for testing # @param [String] str String for testing
# @return [Boolean] If the string has valid window size characters # @return [Boolean] If the string has valid window size characters
def self.is_valid_window_size?(str) def self.is_valid_window_size?(str)
return false if has_non_printable_char?(str) return false if has_non_printable_char?(str)
return false if str.length > 200 return false if str.length > 200
true true
end end
@@ -114,6 +114,16 @@ module Filters
true true
end end
# Verify the CPU type string is valid
# @param [String] str String for testing
# @return [Boolean] If the string has valid CPU type characters
def self.is_valid_cpu?(str)
return false if not is_non_empty_string?(str)
return false if has_non_printable_char?(str)
return false if str.length > 200
true
end
# Verify the browser_plugins string is valid # Verify the browser_plugins string is valid
# @param [String] str String for testing # @param [String] str String for testing
# @return [Boolean] If the string has valid browser plugin characters # @return [Boolean] If the string has valid browser plugin characters