Skip to content

Commit cba5b13

Browse files
committed
Upgrade idna to 3.7
1 parent f404164 commit cba5b13

File tree

6 files changed

+2159
-69
lines changed

6 files changed

+2159
-69
lines changed

news/idna.vendor.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Upgrade idna to 3.6
1+
Upgrade idna to 3.7

src/pip/_vendor/idna/LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2013-2023, Kim Davies and contributors.
3+
Copyright (c) 2013-2024, Kim Davies and contributors.
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

src/pip/_vendor/idna/core.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,11 @@ def valid_contextj(label: str, pos: int) -> bool:
150150
joining_type = idnadata.joining_types.get(ord(label[i]))
151151
if joining_type == ord('T'):
152152
continue
153-
if joining_type in [ord('L'), ord('D')]:
153+
elif joining_type in [ord('L'), ord('D')]:
154154
ok = True
155155
break
156+
else:
157+
break
156158

157159
if not ok:
158160
return False
@@ -162,9 +164,11 @@ def valid_contextj(label: str, pos: int) -> bool:
162164
joining_type = idnadata.joining_types.get(ord(label[i]))
163165
if joining_type == ord('T'):
164166
continue
165-
if joining_type in [ord('R'), ord('D')]:
167+
elif joining_type in [ord('R'), ord('D')]:
166168
ok = True
167169
break
170+
else:
171+
break
168172
return ok
169173

170174
if cp_value == 0x200d:
@@ -236,12 +240,8 @@ def check_label(label: Union[str, bytes, bytearray]) -> None:
236240
if intranges_contain(cp_value, idnadata.codepoint_classes['PVALID']):
237241
continue
238242
elif intranges_contain(cp_value, idnadata.codepoint_classes['CONTEXTJ']):
239-
try:
240-
if not valid_contextj(label, pos):
241-
raise InvalidCodepointContext('Joiner {} not allowed at position {} in {}'.format(
242-
_unot(cp_value), pos+1, repr(label)))
243-
except ValueError:
244-
raise IDNAError('Unknown codepoint adjacent to joiner {} at position {} in {}'.format(
243+
if not valid_contextj(label, pos):
244+
raise InvalidCodepointContext('Joiner {} not allowed at position {} in {}'.format(
245245
_unot(cp_value), pos+1, repr(label)))
246246
elif intranges_contain(cp_value, idnadata.codepoint_classes['CONTEXTO']):
247247
if not valid_contexto(label, pos):
@@ -262,13 +262,8 @@ def alabel(label: str) -> bytes:
262262
except UnicodeEncodeError:
263263
pass
264264

265-
if not label:
266-
raise IDNAError('No Input')
267-
268-
label = str(label)
269265
check_label(label)
270-
label_bytes = _punycode(label)
271-
label_bytes = _alabel_prefix + label_bytes
266+
label_bytes = _alabel_prefix + _punycode(label)
272267

273268
if not valid_label_length(label_bytes):
274269
raise IDNAError('Label too long')

0 commit comments

Comments
 (0)