From a97ad7ebbed093bcae65a4e9b35831368f33706e Mon Sep 17 00:00:00 2001 From: Ed Summers Date: Tue, 9 Aug 2022 18:04:42 -0400 Subject: [PATCH] Ensure CDX status is a string (#739) If a CDXJ entry has a status that is an int that can cause problems in multiple places in pywb. This change ensures that int status lines are converted to str. --- pywb/warcserver/index/cdxobject.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pywb/warcserver/index/cdxobject.py b/pywb/warcserver/index/cdxobject.py index 80dd5351..e5b962a3 100644 --- a/pywb/warcserver/index/cdxobject.py +++ b/pywb/warcserver/index/cdxobject.py @@ -251,7 +251,11 @@ class CDXObject(OrderedDict): @classmethod def json_decode(cls, string): - return json_decode(string, object_pairs_hook=OrderedDict) + cdx_block = json_decode(string, object_pairs_hook=OrderedDict) + # other parts of pywb expect status to be a string and not an integer + if cdx_block and type(cdx_block.get('status')) == int: + cdx_block['status'] = str(cdx_block['status']) + return cdx_block #=================================================================