From 5c406b8d4f082770cbdf54aa08ae15c983d87bff Mon Sep 17 00:00:00 2001 From: Brendan Coles Date: Sun, 23 Apr 2017 03:25:36 +0000 Subject: [PATCH] Add unless is_non_empty_string guard clause to browser filters --- core/filters/browser.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/filters/browser.rb b/core/filters/browser.rb index 550708ed7..177c0b6d6 100644 --- a/core/filters/browser.rb +++ b/core/filters/browser.rb @@ -87,6 +87,7 @@ module Filters # @param [String] str String for testing # @return [Boolean] If the string has valid cookie characters def self.is_valid_cookies?(str) + return false unless is_non_empty_string?(str) return false if has_non_printable_char?(str) return false if str.length > 2000 true @@ -96,6 +97,7 @@ module Filters # @param [String] str String for testing # @return [Boolean] If the string has valid screen size characters def self.is_valid_screen_size?(str) + return false unless is_non_empty_string?(str) return false if has_non_printable_char?(str) return false if str.length > 200 true @@ -105,6 +107,7 @@ module Filters # @param [String] str String for testing # @return [Boolean] If the string has valid window size characters def self.is_valid_window_size?(str) + return false unless is_non_empty_string?(str) return false if has_non_printable_char?(str) return false if str.length > 200 true @@ -114,6 +117,7 @@ module Filters # @param [String] str String for testing # @return [Boolean] If the string has valid system platform characters def self.is_valid_system_platform?(str) + return false unless is_non_empty_string?(str) return false if has_non_printable_char?(str) return false if str.length > 200 true @@ -123,6 +127,7 @@ module Filters # @param [String] str String for testing # @return [Boolean] If the string has valid date stamp characters def self.is_valid_date_stamp?(str) + return false unless is_non_empty_string?(str) return false if has_non_printable_char?(str) return false if str.length > 200 true @@ -144,7 +149,7 @@ module Filters # @note This string can be empty if there are no browser plugins # @todo Verify if the ruby version statement is still necessary def self.is_valid_browser_plugins?(str) - return true unless is_non_empty_string?(str) + return false unless is_non_empty_string?(str) return false if str.length > 1000 if str.encoding === Encoding.find('UTF-8') return (str =~ /[^\w\d\s()-.,';_!\302\256]/u).nil?