allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject git commit: [#6006] Return empty string if path portion isn't latin1-encodable
Date Tue, 09 Apr 2013 18:32:31 GMT
Updated Branches:
  refs/heads/tv/6006 d87b877e2 -> 0a2023727


[#6006] Return empty string if path portion isn't latin1-encodable

Signed-off-by: Tim Van Steenburgh <tvansteenburgh@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/0a202372
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/0a202372
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/0a202372

Branch: refs/heads/tv/6006
Commit: 0a20237278a2b3574ab9e3c69b30852911b96b4d
Parents: d87b877
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Tue Apr 9 18:32:14 2013 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Tue Apr 9 18:32:14 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/helpers.py        |    7 ++++++-
 Allura/allura/tests/test_helpers.py |    6 ++++--
 2 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0a202372/Allura/allura/lib/helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index 583ab32..1035206 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -48,8 +48,13 @@ re_clean_vardec_key = re.compile(r'''\A
 \Z''', re.VERBOSE)
 
 def make_safe_path_portion(ustr):
+    """Return an ascii representation of `ustr`
+
+    Will return an empty string if no char in `ustr`
+    is latin1-encodable.
+    """
     ustr = really_unicode(ustr)
-    s = ustr.encode('utf8', 'ignore')
+    s = ustr.encode('latin1', 'ignore')
     s = AsciiDammit.asciiDammit(s)
     s = s.lower()
     s = '-'.join(re_path_portion_fragment.findall(s))

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0a202372/Allura/allura/tests/test_helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_helpers.py b/Allura/allura/tests/test_helpers.py
index ac979e3..2e80b56 100644
--- a/Allura/allura/tests/test_helpers.py
+++ b/Allura/allura/tests/test_helpers.py
@@ -18,8 +18,10 @@ def setUp(self):
 def test_make_safe_path_portion():
     s = u'Задачи'
     new_s = h.make_safe_path_portion(s)
-    assert len(new_s), len(new_s)
-    assert new_s == new_s.encode('ascii')
+    assert len(new_s) == 0
+    s = 'åß∂ƒ'
+    new_s = h.make_safe_path_portion(s)
+    assert new_s == 'ab'
 
 def test_really_unicode():
     here_dir = path.dirname(__file__)


Mime
View raw message