|
| 1 | +From 9ffbb563891dc0826707dcf9124023b1d9372967 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Ankita Pareek <ankitapareek@microsoft.com> |
| 3 | +Date: Fri, 11 Apr 2025 14:34:28 +0530 |
| 4 | +Subject: [PATCH] python3: Address CVE-2024-3651 |
| 5 | + |
| 6 | +Upstream patch reference: https://github.com/kjd/idna/commit/5beb28b9dd77912c0dd656d8b0fdba3eb80222e7 |
| 7 | + |
| 8 | +Signed-off-by: Ankita Pareek <ankitapareek@microsoft.com> |
| 9 | +--- |
| 10 | + _vendor/idna/core.py | 16 ++++++++-------- |
| 11 | + 1 file changed, 8 insertions(+), 8 deletions(-) |
| 12 | + |
| 13 | +diff --git a/pip/_vendor/idna/core.py b/pip/_vendor/idna/core.py |
| 14 | +index 4f30037..aea17ac 100644 |
| 15 | +--- a/pip/_vendor/idna/core.py |
| 16 | ++++ b/pip/_vendor/idna/core.py |
| 17 | +@@ -150,9 +150,11 @@ def valid_contextj(label: str, pos: int) -> bool: |
| 18 | + joining_type = idnadata.joining_types.get(ord(label[i])) |
| 19 | + if joining_type == ord('T'): |
| 20 | + continue |
| 21 | +- if joining_type in [ord('L'), ord('D')]: |
| 22 | ++ elif joining_type in [ord('L'), ord('D')]: |
| 23 | + ok = True |
| 24 | + break |
| 25 | ++ else: |
| 26 | ++ break |
| 27 | + |
| 28 | + if not ok: |
| 29 | + return False |
| 30 | +@@ -162,9 +164,11 @@ def valid_contextj(label: str, pos: int) -> bool: |
| 31 | + joining_type = idnadata.joining_types.get(ord(label[i])) |
| 32 | + if joining_type == ord('T'): |
| 33 | + continue |
| 34 | +- if joining_type in [ord('R'), ord('D')]: |
| 35 | ++ elif joining_type in [ord('R'), ord('D')]: |
| 36 | + ok = True |
| 37 | + break |
| 38 | ++ else: |
| 39 | ++ break |
| 40 | + return ok |
| 41 | + |
| 42 | + if cp_value == 0x200d: |
| 43 | +@@ -236,12 +240,8 @@ def check_label(label: Union[str, bytes, bytearray]) -> None: |
| 44 | + if intranges_contain(cp_value, idnadata.codepoint_classes['PVALID']): |
| 45 | + continue |
| 46 | + elif intranges_contain(cp_value, idnadata.codepoint_classes['CONTEXTJ']): |
| 47 | +- try: |
| 48 | +- if not valid_contextj(label, pos): |
| 49 | +- raise InvalidCodepointContext('Joiner {} not allowed at position {} in {}'.format( |
| 50 | +- _unot(cp_value), pos+1, repr(label))) |
| 51 | +- except ValueError: |
| 52 | +- raise IDNAError('Unknown codepoint adjacent to joiner {} at position {} in {}'.format( |
| 53 | ++ if not valid_contextj(label, pos): |
| 54 | ++ raise InvalidCodepointContext('Joiner {} not allowed at position {} in {}'.format( |
| 55 | + _unot(cp_value), pos+1, repr(label))) |
| 56 | + elif intranges_contain(cp_value, idnadata.codepoint_classes['CONTEXTO']): |
| 57 | + if not valid_contexto(label, pos): |
| 58 | +-- |
| 59 | +2.34.1 |
| 60 | + |
0 commit comments