You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by ac...@apache.org on 2013/04/16 14:29:17 UTC

[27/50] git commit: [#6006] Return empty string if path portion isn't latin1-encodable

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

Signed-off-by: Tim Van Steenburgh <tv...@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/76800ef6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/76800ef6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/76800ef6

Branch: refs/heads/acs2/5518
Commit: 76800ef6445d53b5a4ffa4e56a7ce6077b465508
Parents: 960602a
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Tue Apr 9 18:32:14 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 10 14:20:30 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/76800ef6/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/76800ef6/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__)