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