EmailMessage.get_filename() not unquoting url encodings
未關閉
還沒有人認領這個 Issue。
stdlib
topic-email
type-bug
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
Bug description:
import requests
from email.message import EmailMessage
def get_filename_from_url(url, url_response=None):
if url_response == None:
url_response = requests.get(url)
url_response.raise_for_status()
content_disposition = url_response.headers.get("Content-Disposition")
if content_disposition:
email_message = EmailMessage()
email_message["Content-Disposition"] = content_disposition
return email_message.get_filename()
url = "https://www.gsi.gov.in/webcenter/ShowProperty;jsessionid=yv2xehEKwHR0ZHf64V2sMbrFzRSeSGCvcxDVr9F4_rbXBVtcgKbl!1598077039!1556223610?nodeId=%2FUCM%2FDCPORT1GSIGOVI063041%2F%2FidcPrimaryFile&revision=latestreleased"
get_filename_from_url(url)
output
annoncement_of%20computer%20application%20_rti_er%20_16122014.pdf
if i use
from urllib.parse import unquote
unquote(email_message.get_filename())
i am getting unquoted output
annoncement_of computer application _rti_er _16122014.pdf
why a different unquote function is used in EmailMessage.get_filename() ?
CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 EmailMessage.get_filename() 入口點開始,使用提供的 URL 和標頭值重現回報的 Content-Disposition 行為。將其解碼行為與 urllib.parse.unquote 進行比較,接著確立預期的檔名處理方式;如果 issue 確認存在 bug,則新增或更新回歸測試涵蓋範圍。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- backend
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100