Skip to content

Commit

Permalink
Validation after normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
gogobd committed Feb 14, 2020
1 parent ad2ca66 commit 7a8f107
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/zope/schema/_bootstrapfields.py
@@ -1,5 +1,3 @@
# coding=utf-8

##############################################################################
#
# Copyright (c) 2002 Zope Foundation and Contributors.
Expand Down Expand Up @@ -534,9 +532,9 @@ def fromUnicode(self, str):
...
zope.schema._bootstrapinterfaces.ConstraintNotSatisfied: (u'foo spam', '')
"""
self.validate(str)
if self.unicode_normalization:
str = unicodedata.normalize(self.unicode_normalization, str)
self.validate(str)
return str


Expand Down
4 changes: 1 addition & 3 deletions src/zope/schema/tests/test__bootstrapfields.py
@@ -1,5 +1,3 @@
# coding=utf-8

##############################################################################
#
# Copyright (c) 2012 Zope Foundation and Contributors.
Expand Down Expand Up @@ -966,7 +964,7 @@ def test_fromUnicode_hit(self):
self.assertEqual(txt.fromUnicode(deadbeef), deadbeef)

def test_normalization(self):
deadbeef = unicodedata.normalize('NFD', u'ÄÖÜ')
deadbeef = unicodedata.normalize('NFD', b'\xc3\x84\xc3\x96\xc3\x9c'.decode('utf-8'))
txt = self._makeOne()
self.assertEqual(
[unicodedata.name(c) for c in txt.fromUnicode(deadbeef)],
Expand Down

0 comments on commit 7a8f107

Please sign in to comment.