From a6425032292ddf66543eb6d3f3b09891511c58e2 Mon Sep 17 00:00:00 2001 From: Zhao Yang <53465358+sz134055@users.noreply.github.com> Date: Tue, 12 Nov 2024 17:49:57 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=EF=BC=88#380,#378=EF=BC=89?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A2=98=E5=9E=8B=E5=88=A4=E6=96=AD=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E6=BC=8F=E6=B4=9E=E5=AF=BC=E8=87=B4=E7=9A=84=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E9=80=80=E5=87=BA=20(#384)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix:(#380,#378)修复题型判断逻辑漏洞导致的异常退出 --- api/decode.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/decode.py b/api/decode.py index 46451de7..7fe74639 100644 --- a/api/decode.py +++ b/api/decode.py @@ -200,6 +200,8 @@ def replace_rtn(text): # 尝试使用 data 属性来判断题型 q_type_code = div_tag.find('div',class_='TiMu').attrs['data'] + q_type = '' + # 此处可能需要完善更多题型的判断 if q_type_code == '0': q_type = 'single' elif q_type_code == '1': @@ -208,6 +210,9 @@ def replace_rtn(text): q_type = 'completion' elif q_type_code == '3': q_type = 'judgement' + else: + logger.info("未知题型代码 -> "+q_type_code) + q_type = 'unknown' # 避免出现未定义取值错误 form_data["questions"].append({ 'id': div_tag.attrs["data"],