Commit d3584e8
committed
Let hostname() accept a bare single-label name with the RFC 1034 dot
hostname("yu", rfc_1034=True) passes today through the maybe_simple
fast path, since _simple_hostname_regex has no problem with a lone
alphanumeric label. hostname("yu.", rfc_1034=True) doesn't, because
that regex has no notion of a trailing dot at all, and the fallback to
domain() requires at least a second label before the TLD. So the exact
same name is accepted or rejected purely based on whether it carries
the dot RFC 1034 is supposed to permit, which is backwards from what
that flag promises.
Added a small wrapper around the simple-hostname match that strips a
lone trailing dot first when rfc_1034 is set, mirroring what domain()
already does for its own regex. Left everything else about the simple
path untouched, so this doesn't change hostname() for the vast
majority of callers who never pass rfc_1034.
Fixes GH-442.1 parent 70de324 commit d3584e8
2 files changed
Lines changed: 23 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
32 | 46 | | |
33 | 47 | | |
34 | 48 | | |
| |||
115 | 129 | | |
116 | 130 | | |
117 | 131 | | |
118 | | - | |
| 132 | + | |
119 | 133 | | |
120 | 134 | | |
121 | 135 | | |
122 | 136 | | |
123 | 137 | | |
124 | 138 | | |
125 | | - | |
| 139 | + | |
126 | 140 | | |
127 | 141 | | |
128 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| |||
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
63 | 70 | | |
64 | 71 | | |
65 | 72 | | |
| |||
0 commit comments