[Python-modules-commits] [ldif3] 02/09: Import ldif3_3.2.2.orig.tar.gz

Michael Fladischer fladi at moszumanska.debian.org
Fri Mar 17 08:26:17 UTC 2017


This is an automated email from the git hooks/post-receive script.

fladi pushed a commit to branch master
in repository ldif3.

commit ea59cdd7e254576a52496301d8bfa47166c739b3
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date:   Fri Mar 17 08:34:37 2017 +0100

    Import ldif3_3.2.2.orig.tar.gz
---
 CHANGES.rst | 11 +++++++++--
 ldif3.py    |  6 ++++--
 tests.py    |  5 +++++
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/CHANGES.rst b/CHANGES.rst
index 064ae13..8bc38a1 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,8 +1,15 @@
+3.2.2 (2017-02-07)
+------------------
+
+-   Fix detection of unsafe strings in ``unparse`` (See `#7
+    <https://github.com/xi/ldif3/pull/7>`_)
+
+
 3.2.1 (2016-12-27)
 ------------------
 
--   Ignore non-unicode characters in "dn" in non-strict mode. (Fixes `#4
-    https://github.com/xi/ldif3/issues/6`_)
+-   Ignore non-unicode characters in "dn" in non-strict mode. (Fixes `#5
+    <https://github.com/xi/ldif3/issues/6>`_)
 
 
 3.2.0 (2016-06-03)
diff --git a/ldif3.py b/ldif3.py
index 7b1276b..4799650 100644
--- a/ldif3.py
+++ b/ldif3.py
@@ -14,7 +14,7 @@ except ImportError:  # pragma: nocover
     from urllib.parse import urlparse
     from urllib.request import urlopen
 
-__version__ = '3.2.1'
+__version__ = '3.2.2'
 
 __all__ = [
     # constants
@@ -48,7 +48,9 @@ def is_dn(s):
     return rm is not None and rm.group(0) == s
 
 
-UNSAFE_STRING_PATTERN = '(^[ :<]|[\000\n\r\200-\377])'
+UNSAFE_STRING_PATTERN = (
+    '(^[^\x01-\x09\x0b-\x0c\x0e-\x1f\x21-\x39\x3b\x3d-\x7f]'
+    '|[^\x01-\x09\x0b-\x0c\x0e-\x7f])')
 UNSAFE_STRING_RE = re.compile(UNSAFE_STRING_PATTERN)
 
 
diff --git a/tests.py b/tests.py
index 8264480..2647c97 100644
--- a/tests.py
+++ b/tests.py
@@ -392,3 +392,8 @@ class TestLDIFWriter(unittest.TestCase):
         self.w.unparse(u'cn=Björn J Jensen', {u'foo': [u'bar']})
         value = self.stream.getvalue()
         self.assertEqual(value, b'dn:: Y249QmrDtnJuIEogSmVuc2Vu\nfoo: bar\n\n')
+
+    def test_unparse_uniqode(self):
+        self.w.unparse("o=x", {'test': [u'日本語']})
+        value = self.stream.getvalue()
+        self.assertEqual(value, b'dn: o=x\ntest:: 5pel5pys6Kqe\n\n')

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/ldif3.git



More information about the Python-modules-commits mailing list