Escape any invalid characters in HTTP URL, and uppercase all escapes.
(path)
| 676 | def uppercase_escaped_char(match): |
| 677 | return "%%%s" % match.group(1).upper() |
| 678 | def escape_path(path): |
| 679 | """Escape any invalid characters in HTTP URL, and uppercase all escapes.""" |
| 680 | # There's no knowing what character encoding was used to create URLs |
| 681 | # containing %-escapes, but since we have to pick one to escape invalid |
| 682 | # path characters, we pick UTF-8, as recommended in the HTML 4.0 |
| 683 | # specification: |
| 684 | # http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.2.1 |
| 685 | # And here, kind of: draft-fielding-uri-rfc2396bis-03 |
| 686 | # (And in draft IRI specification: draft-duerst-iri-05) |
| 687 | # (And here, for new URI schemes: RFC 2718) |
| 688 | path = urllib.parse.quote(path, HTTP_PATH_SAFE) |
| 689 | path = ESCAPED_CHAR_RE.sub(uppercase_escaped_char, path) |
| 690 | return path |
| 691 | |
| 692 | def reach(h): |
| 693 | """Return reach of host h, as defined by RFC 2965, section 1. |
searching dependent graphs…