From 482199d29cc3ab711410cadbb3d0e58d0ae804f3 Mon Sep 17 00:00:00 2001 From: Jon Schewe Date: Mon, 11 Jul 2022 06:50:38 -0500 Subject: [PATCH] Avoid application crash on invalid user input If the user inputs an invalid date this change keeps the application from crashing when such a date is found. The invalid date information is reported to the user in the log. Fixes #12658. --- gramps/plugins/webreport/basepage.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gramps/plugins/webreport/basepage.py b/gramps/plugins/webreport/basepage.py index 4520b9860..017517350 100644 --- a/gramps/plugins/webreport/basepage.py +++ b/gramps/plugins/webreport/basepage.py @@ -2873,9 +2873,17 @@ class BasePage: # pylint: disable=C1001 if self.reference_sort: role = "" elif role[1:2] == ':': + # format of role is role_type:ISO date string + if role.count(':') > 1: + print("Invalid date :", role[2:], " for individual with ID:", gid, + ". Please, use the 'verify the data' tool to correct this.") + cal, role = role.split(':', 1) + else: + cal, role = role.split(':') + # cal is the original calendar - cal, role = role.split(':') - # conver ISO date to Date for translation. + + # convert ISO date to Date for translation. # all modifiers are in english, so convert them # to the local language if len(role.split(' - ')) > 1: