urljoin works incorrectly for two path-relative URLs involving . and ..
@serhiy-storchaka 已經在處理了。
開始於 2024年11月11日。
評估
這個 Issue 還沒有評估資料。
描述
Bug report
urllib.parse.urljoin is usually used to join a normalized absolute URL with a relative URL, and it generally works for that purpose. But if it’s used to join two path-relative URLs, it produces incorrect results in many cases when . or .. is involved.
>>> from urllib.parse import urljoin
>>> urljoin('a', 'b') # ok
'b'
>>> urljoin('a/', 'b') # ok
'a/b'
>>> urljoin('a', '.') # expected . or ./
'/'
>>> urljoin('a', '..') # expected .. or ../
'/'
>>> urljoin('..', 'b') # expected ../b
'b'
>>> urljoin('../a', 'b') # expected ../b
'b'
>>> urljoin('a', '../b') # expected ../b
'b'
>>> urljoin('../a', '../b') # expected ../../b
'b'
>>> urljoin('a/..', 'b') # expected b
'a/b'
There are also some problems when the base is a non-normalized absolute URL:
>>> urljoin('http://host/a/..', 'b') # expected http://host/b
'http://host/a/b'
Your environment
- CPython versions tested on: 3.10.5, 3.11.0rc1
- Operating system and architecture: NixOS 21.11 amd64
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- 平均合併
- 1 天 9 小時
- 30 天內合併 PR
- 558
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python/cpython 的其他 Issue
-
docs pending
難度 2/5 1-3 小時 新手友好度 78/100
-
stdlib type-feature
難度 2/5 1-3 小時 新手友好度 78/100
-
stdlib type-feature
難度 2/5 1-3 小時 新手友好度 72/100
-
build type-bug
難度 2/5 1-3 小時 新手友好度 76/100
-
stdlib topic-email type-feature
難度 2/5 1-3 小時 新手友好度 70/100
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 74/100
bancolombia/sentinel#23 ·
-
test md 未關閉CI
難度 2/5 1-3 小時 新手友好度 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
難度 2/5 1-3 小時 新手友好度 74/100
langchain-ai/deepagents#6450 ·
-
bug client
難度 2/5 1-3 小時 新手友好度 88/100
-
難度 2/5 1-3 小時 新手友好度 74/100