From 2c40be31a2b30cb0939a6f71e9459c8bf40f572e Mon Sep 17 00:00:00 2001 From: Imran Sobir Date: Tue, 7 Feb 2017 16:15:10 +0500 Subject: [PATCH] Prevent crash if invalid date is passed to qute:history. --- qutebrowser/browser/qutescheme.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/qutebrowser/browser/qutescheme.py b/qutebrowser/browser/qutescheme.py index 9ece0e1de..1e996d1f2 100644 --- a/qutebrowser/browser/qutescheme.py +++ b/qutebrowser/browser/qutescheme.py @@ -165,11 +165,13 @@ def qute_bookmarks(_url): def qute_history(url): """Handler for qute:history. Display history.""" # Get current date from query parameter, if not given choose today. - url_query_date = QUrlQuery(url).queryItemValue("date") - if url_query_date: - curr_date = datetime.datetime.strptime(url_query_date, "%Y-%m-%d").date() - else: - curr_date = datetime.date.today() + curr_date = datetime.date.today() + try: + query_date = QUrlQuery(url).queryItemValue("date") + if query_date: + curr_date = datetime.datetime.strptime(query_date, "%Y-%m-%d").date() + except ValueError: + log.misc.error("Invalid date passed to qute:history: {}.".format(query_date)) one_day = datetime.timedelta(days=1) next_date = curr_date + one_day