Skip to content

Commit aa2a2fe

Browse files
committed
added character length for regex check
1 parent 3fac14b commit aa2a2fe

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

splitio/client/input_validator.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def _check_string_not_empty(value, name, operation):
8080
return True
8181

8282

83-
def _check_string_matches(value, operation, pattern, name):
83+
def _check_string_matches(value, operation, pattern, name, length):
8484
"""
8585
Check if value is adhere to a regular expression passed.
8686
@@ -98,9 +98,9 @@ def _check_string_matches(value, operation, pattern, name):
9898
'%s: you passed %s, event_type must ' +
9999
'adhere to the regular expression %s. ' +
100100
'This means %s must be alphanumeric, cannot be more ' +
101-
'than 80 characters long, and can only include a dash, underscore, ' +
101+
'than %s characters long, and can only include a dash, underscore, ' +
102102
'period, or colon as separators of alphanumeric characters.',
103-
operation, value, pattern, name
103+
operation, value, pattern, name, length
104104
)
105105
return False
106106
return True
@@ -323,7 +323,7 @@ def validate_event_type(event_type):
323323
if (not _check_not_null(event_type, 'event_type', 'track')) or \
324324
(not _check_is_string(event_type, 'event_type', 'track')) or \
325325
(not _check_string_not_empty(event_type, 'event_type', 'track')) or \
326-
(not _check_string_matches(event_type, 'track', EVENT_TYPE_PATTERN, 'an event name')):
326+
(not _check_string_matches(event_type, 'track', EVENT_TYPE_PATTERN, 'an event name', 80)):
327327
return None
328328
return event_type
329329

@@ -591,7 +591,7 @@ def validate_flag_sets(flag_sets, method_name):
591591
flag_set = _remove_empty_spaces(flag_set, 'flag set', method_name)
592592
flag_set = _convert_str_to_lower(flag_set, 'flag set', method_name)
593593

594-
if not _check_string_matches(flag_set, method_name, _FLAG_SETS_REGEX, 'a flag set'):
594+
if not _check_string_matches(flag_set, method_name, _FLAG_SETS_REGEX, 'a flag set', 50):
595595
continue
596596

597597
sanitized_flag_sets.add(flag_set)

tests/client/test_input_validator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,10 +666,10 @@ def test_track(self, mocker):
666666
assert _logger.error.mock_calls == [
667667
mocker.call("%s: you passed %s, event_type must adhere to the regular "
668668
"expression %s. This means "
669-
"%s must be alphanumeric, cannot be more than 80 "
669+
"%s must be alphanumeric, cannot be more than %s "
670670
"characters long, and can only include a dash, underscore, "
671671
"period, or colon as separators of alphanumeric characters.",
672-
'track', '@@', '^[a-zA-Z0-9][-_.:a-zA-Z0-9]{0,79}$', 'an event name')
672+
'track', '@@', '^[a-zA-Z0-9][-_.:a-zA-Z0-9]{0,79}$', 'an event name', 80)
673673
]
674674

675675
_logger.reset_mock()

0 commit comments

Comments
 (0)