MagicStack / MagicStack/asyncpg
.pgpass file support handles backslash escapes incorrectly; should de-escape values
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 8.1k
- 派生
- 468
- PR 合并指标
- 30 天内没有已合并 PR
描述
https://www.postgresql.org/docs/current/libpq-pgpass.html isn't fully explicit about how to handle backslash escapes in the `.pgpass` file, however it's reasonably clear from the phrasing that backslashes serve only to escape backslashes and colons and therefore aren't considered part of the value they're used in. E.g., a `.pgpass` row of …
```
*:*:test\:db:test\\:password from pgpass with escapes
```
conveys:
- a database name of `test:db`, not `test\:db`
- a user name of `test\`, not `test\\`
I ran into this problem because I have a password of `4:K1…`, encoded as `4\:K1…`, and it works with `psql` but not `asyncpg`. Once I remove the backslash from `.pgpass`, it starts working with `asyncpg` but failing with `psql`.
I would've provided a failing test and even a code change, but I can't get `python setup.py test` or `pip install -e .[test]` to work in a run-of-the-mill Python 3.12 virtualenv on my run-of-the-mill MacOS.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先解决针对 `python setup.py test` 或 `pip install -e .[test]` 报告的 Python 3.12 测试设置问题,然后定位 asyncpg 对 `.pgpass` 的处理。为转义的冒号和反斜杠添加覆盖测试,并在这些值能够与 `psql` 一致地取消转义时,认为该 issue 已完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- postgresql, python
- 领域
- databases
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100