urllib.robotparser.RobotFileParser.can_fetch crashes on a malformed URL
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
Bug description:
urllib.robotparser.RobotFileParser.can_fetch is documented to return a bool,
but it passes url straight to urllib.parse._urlsplit, so a malformed URL
(an unterminated IPv6 authority) raises a bare ValueError instead of a
result:
import urllib.robotparser
p = urllib.robotparser.RobotFileParser()
p.parse(["User-agent: *", "Disallow: /"])
p.can_fetch("*", "http://[::1") # ValueError: Invalid IPv6 URL
The url argument is crawl-frontier-controlled (it comes from parsed pages).
Proposed behavior: a URL that cannot be parsed matches no rule, so can_fetch
returns True (RFC 9309 default that access is not restricted when no rule
applies), rather than raising or being conservatively False.
This is a sibling of #153404 (robotparser raising ValueError on a non-decimal
digit in Crawl-delay / Request-rate); the sink there is the robots.txt
content, here it is the url argument.
CPython versions tested on:
3.13, 3.14, 3.15
Operating systems tested on:
macOS
Linked PRs
- gh-153796
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu tại urllib.robotparser.RobotFileParser.can_fetch và tái hiện trường hợp URL không hợp lệ với authority IPv6 chưa được kết thúc. Kiểm tra cách urllib.parse._urlsplit xử lý đầu vào. Hoàn thành có nghĩa là can_fetch trả về True thay vì phát sinh ValueError, kèm theo coverage cho hành vi của URL không hợp lệ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- networking
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 25/100