incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject git commit: [#6006] Make safe path portion out of non-latin1 chars
Date Tue, 09 Apr 2013 13:18:02 GMT
Updated Branches:
  refs/heads/tv/6006 [created] d87b877e2


[#6006] Make safe path portion out of non-latin1 chars

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/d87b877e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/d87b877e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/d87b877e

Branch: refs/heads/tv/6006
Commit: d87b877e2b03abefc59ad8ce1c29bbdaa2287001
Parents: b08571f
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Tue Apr 9 13:17:41 2013 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Tue Apr 9 13:17:41 2013 +0000

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


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d87b877e/Allura/allura/lib/helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index eeee7bc..583ab32 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -49,7 +49,7 @@ re_clean_vardec_key = re.compile(r'''\A
 
 def make_safe_path_portion(ustr):
     ustr = really_unicode(ustr)
-    s = ustr.encode('latin-1', 'ignore')
+    s = ustr.encode('utf8', '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/d87b877e/Allura/allura/tests/test_helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_helpers.py b/Allura/allura/tests/test_helpers.py
index 4829549..ac979e3 100644
--- a/Allura/allura/tests/test_helpers.py
+++ b/Allura/allura/tests/test_helpers.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 from os import path
 from mock import Mock, patch
 
@@ -14,6 +15,12 @@ def setUp(self):
     """Method called by nose before running each test"""
     setup_basic_test()
 
+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')
+
 def test_really_unicode():
     here_dir = path.dirname(__file__)
     s = h.really_unicode('\xef\xbb\xbf<?xml version="1.0" encoding="utf-8" ?>')


Mime
View raw message