FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.15] gh-155292: Don't consider Unicode codepoint attributes outside RFC 3454 (GH-155293) by miss-islington · Pull Request #156017 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .h  (1) .py  (5) .rst  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
gh-155292: Don't consider Unicode codepoint attributes outside RFC 34…
…54 (GH-155293)

Due to a bug, some Unicode codepoint attributes were considered
for characters not yet defined in Unicode 3.2.0 or attributes
which changed in later Unicode versions. RFC 3454 (StringPrep)
requires using Unicode 3.2.0 strictly.

(cherry picked from commit 7e109d0)

Co-authored-by: Seth Larson <seth@python.org>
Co-authored-by: Stan Ulbrych <89152624+stanfromireland@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
  • Loading branch information
3 people authored and miss-islington committed Aug 18, 2026
commit f107388d346eed749271efa1f366dec0b3768a37
323 changes: 257 additions & 66 deletions Lib/stringprep.py

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions Lib/test/test_codecs.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,15 @@ def test_builtin_encode(self):
self.assertEqual("pyth\xf6n.org".encode("idna"), b"xn--pythn-mua.org")
self.assertEqual("pyth\xf6n.org.".encode("idna"), b"xn--pythn-mua.org.")

@support.subTests(['unicode', 'encoded'], [
('\N{CHEROKEE LETTER A}\N{CHEROKEE LETTER A}', b"xn--58da"),
('\N{GEORGIAN CAPITAL LETTER AN}.', b"xn--7md."),
('\N{CYRILLIC LETTER PALOCHKA}.example', b"xn--d5a.example"),
('\N{ROMAN NUMERAL REVERSED ONE HUNDRED}.example.', b"xn--q5g.example."),
])
def test_new_unicode_case_folding(self, unicode, encoded):
self.assertEqual(unicode.encode("idna"), encoded)

def test_builtin_encode_invalid(self):
for case, expected in self.invalid_encode_testcases:
with self.subTest(case=case, expected=expected):
Expand Down
22 changes: 10 additions & 12 deletions Lib/test/test_unicodedata.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def test_category(self):
self.assertRaises(TypeError, self.db.category, 'xx')

def test_bidirectional(self):
self.assertEqual(self.db.bidirectional('\uFFFE'), 'BN')
self.assertEqual(self.db.bidirectional('\uFFFE'), '' if self.old else 'BN')
self.assertEqual(self.db.bidirectional(' '), 'WS')
self.assertEqual(self.db.bidirectional('A'), 'L')
self.assertEqual(self.db.bidirectional('\U00020000'), 'L')
Expand Down Expand Up @@ -350,15 +350,13 @@ def test_bidirectional(self):
self.assertRaises(TypeError, self.db.bidirectional, 'xx')

def test_bidirectional_unassigned(self):
if self.old:
return
self.assertEqual(self.db.bidirectional('\u0378'), 'L')
self.assertEqual(self.db.bidirectional('\u077F'), 'AL')
self.assertEqual(self.db.bidirectional('\u20CF'), 'ET')
self.assertEqual(self.db.bidirectional('\u0590'), 'R')
self.assertEqual(self.db.bidirectional('\uFFFF'), 'BN')
self.assertEqual(self.db.bidirectional('\U0001FFFE'), 'BN')
self.assertEqual(self.db.bidirectional('\U00010D01'), 'AL')
self.assertEqual(self.db.bidirectional('\u0378'), '' if self.old else 'L')
self.assertEqual(self.db.bidirectional('\u077F'), '' if self.old else 'AL')
self.assertEqual(self.db.bidirectional('\u20CF'), '' if self.old else 'ET')
self.assertEqual(self.db.bidirectional('\u0590'), '' if self.old else 'R')
self.assertEqual(self.db.bidirectional('\uFFFF'), '' if self.old else 'BN')
self.assertEqual(self.db.bidirectional('\U0001FFFE'), '' if self.old else 'BN')
self.assertEqual(self.db.bidirectional('\U00010D01'), '' if self.old else 'AL')

def test_decomposition(self):
self.assertEqual(self.db.decomposition('\uFFFE'),'')
Expand Down Expand Up @@ -1104,9 +1102,9 @@ def test_block_invalid_input(self):
class Unicode_3_2_0_FunctionsTest(unittest.TestCase, BaseUnicodeFunctionsTest):
db = unicodedata.ucd_3_2_0
old = True
expectedchecksum = ('cb5bbbd1f55b67371e18222b90a8e21c87f16b72'
expectedchecksum = ('883824cb6c0ccf994e4451ebf281e2d6d479af47'
if quicktest else
'74936dffe949d99203a47e6a66565b2fc337bae7')
'68cd01e2c680b851c1fcab012efb5635b2229c2b')


class UnicodeMiscTest(unittest.TestCase):
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Change the :mod:`stringprep` module and :mod:`encodings.idna` codec to not
consider Unicode codepoint attributes beyond those defined in :rfc:`3454`.
Loading
Loading

Back | FazBrowse Home | New Git URL