Skip to content

Commit

Permalink
fix:(#380,#378)修复题型判断逻辑漏洞导致的异常退出 (#384)
Browse files Browse the repository at this point in the history
* fix:(#380,#378)修复题型判断逻辑漏洞导致的异常退出
  • Loading branch information
sz134055 authored Nov 12, 2024
1 parent 7742460 commit a642503
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand All @@ -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"],
Expand Down

0 comments on commit a642503

Please sign in to comment.