incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [2/2] git commit: [#6006] Make safe path portion out of non-latin1 chars
Date Wed, 10 Apr 2013 14:22:08 GMT
[#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/960602a9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/960602a9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/960602a9

Branch: refs/heads/master
Commit: 960602a907db8439a40674b0d6ac7dd0fbd30c04
Parents: 5207de0
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Tue Apr 9 13:17:41 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Apr 10 14:20:30 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/960602a9/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/960602a9/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