From 3e7135d59b232a1aaedb8345bb595516b35d1ef5 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 02 2021 11:12:06 +0000 Subject: [PATCH 1/2] Handle the situation when user_getfield('cla') returns None This can happen if we don't query the OIDC provider correctly (with the correct scopes) and in that situation fedocal ends up crashing. With this commit, it will assume the list of signed agreements is empty and the application will keep on going. Signed-off-by: Pierre-Yves Chibon --- diff --git a/fedocal/__init__.py b/fedocal/__init__.py index 365e956..1ab3355 100644 --- a/fedocal/__init__.py +++ b/fedocal/__init__.py @@ -267,7 +267,7 @@ def set_session(): 'timezone': OIDC.user_getfield('zoneinfo'), 'cla_done': \ 'http://admin.fedoraproject.org/accounts/cla/done' \ - in OIDC.user_getfield('cla'), + in (OIDC.user_getfield('cla') or []), 'groups': OIDC.user_getfield('groups'), }) flask.g.fas_user = flask.session.fas_user From 3a75109ae8a4aed812771ee875ca5e2acf37b193 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 02 2021 11:13:36 +0000 Subject: [PATCH 2/2] Enforce using UTF-8 In python3 locale.normalize('en') returns 'en_US.ISO8859-1' but we prefer to default to UTF-8, so if there is a '.' in the local return, just ignore what is after it and force using UTF-8. Signed-off-by: Pierre-Yves Chibon --- diff --git a/fedocal/fedocallib/fedora_calendar.py b/fedocal/fedocallib/fedora_calendar.py index 391f3b0..b523f61 100644 --- a/fedocal/fedocallib/fedora_calendar.py +++ b/fedocal/fedocallib/fedora_calendar.py @@ -44,6 +44,8 @@ class FedocalCalendar(calendar.LocaleHTMLCalendar): babel_locale = fedocal.get_locale() if babel_locale: cal_locale = locale.normalize(babel_locale) + if '.' in cal_locale: + cal_locale = "%s.UTF-8" % cal_locale.partition('.')[0] except: pass super(FedocalCalendar, self).__init__(locale=cal_locale)