xmlrpc.client.loads raises IndexError on a malformed struct
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- PR 合併指標
- PR 指標待擷取
描述
Bug description
xmlrpc.client.loads() raises a raw IndexError instead of xmlrpc.client.ResponseError when unmarshalling a <struct> that contains a <member> with a <name> but no <value>.
Unmarshaller.end_struct iterates the stacked items in pairs (items[i], items[i+1]). A <member> missing its <value> leaves an odd number of items, so items[i+1] raises IndexError.
The unmarshaller already raises ResponseError for sibling malformed cases (empty stack at line 640, unknown tag inside <data> at line 663).
Reproducer:
import xmlrpc.client
data = (b'<?xml version="1.0"?>'
b'<methodResponse><params><param><value>'
b'<struct><member><name>k</name></member></struct>'
b'</value></param></params></methodResponse>')
xmlrpc.client.loads(data)
# IndexError: list index out of range
Expected: xmlrpc.client.ResponseError.
CPython versions tested on
3.13, 3.14, 3.15, main
Operating systems tested on
macOS
Linked PRs
- gh-153805
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 Unmarshaller.end_struct 開始,issue 在這裡指出了會引發 IndexError 的成對迭代,並將其與第 640 行和第 663 行附近現有的格式錯誤輸入處理進行比較。當 reproducer 引發 xmlrpc.client.ResponseError 而不是 IndexError 時,即表示完成;關聯的 PR gh-153805 表明這項工作已經在進行中。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- api
- Issue 類型
- 缺陷
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 25/100