From 42853fadad5879682a3ba65f8aa250d5eb353b0c Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Mon, 2 Jan 2023 09:44:10 -0800 Subject: [PATCH] work around negotiator crash with Chrome's new Accept header https://github.com/CottageLabs/negotiator/issues/6 . thanks for reporting @gregorlove! --- redirect.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/redirect.py b/redirect.py index ea92206..9727d4f 100644 --- a/redirect.py +++ b/redirect.py @@ -76,7 +76,11 @@ def redir(to): # check conneg, serve AS2 if requested accept = request.headers.get('Accept') if accept: - negotiated = _negotiator.negotiate(accept) + try: + negotiated = _negotiator.negotiate(accept) + except ValueError: + # work around https://github.com/CottageLabs/negotiator/issues/6 + negotiated = None if negotiated: type = str(negotiated.content_type) if type in (CONTENT_TYPE_AS2, CONTENT_TYPE_AS2_LD):