Skip to content

Commit fe9bfa2

Browse files
authored
Merge pull request #479 from adlnet/timestamp-8601-rejectio
added offset checks for the ISO 8601 issue
2 parents f99e258 + 12f462e commit fe9bfa2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lrs/utils/StatementValidator.py

+12
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ def validate_statement(self, stmt):
197197
timestamp = stmt['timestamp']
198198
try:
199199
parse_datetime(timestamp)
200+
201+
# Reject statements that don't comply with ISO 8601 offsets
202+
if timestamp.endswith("-00") or timestamp.endswith("-0000") or timestamp.endswith("-00:00"):
203+
self.return_error(
204+
"Timestamp error - Statement Timestamp Illegal offset (-00, -0000, or -00:00) %s" % timestamp)
205+
200206
except Exception as e:
201207
self.return_error(
202208
"Timestamp error - There was an error while parsing the date from %s -- Error: %s" % (timestamp, e.message))
@@ -640,6 +646,12 @@ def validate_substatement(self, substmt):
640646
timestamp = substmt['timestamp']
641647
try:
642648
parse_datetime(timestamp)
649+
650+
# Reject statements that don't comply with ISO 8601 offsets
651+
if timestamp.endswith("-00") or timestamp.endswith("-0000") or timestamp.endswith("-00:00"):
652+
self.return_error(
653+
"Timestamp error - Substatement Timestamp Illegal offset (-00, -0000, or -00:00) %s" % timestamp)
654+
643655
except Exception as e:
644656
self.return_error(
645657
"Timestamp error - There was an error while parsing the date from %s -- Error: %s" % (timestamp, e.message))

0 commit comments

Comments
 (0)