allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject git commit: [#6189] allow uppercase characters in code repos' relaxed mount point names
Date Tue, 07 May 2013 20:56:32 GMT
Updated Branches:
  refs/heads/db/6189 [created] 09bd5a745


[#6189] allow uppercase characters in code repos' relaxed mount point names


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

Branch: refs/heads/db/6189
Commit: 09bd5a74592295b2dd276e8bd402f0b52c7b2af8
Parents: 9bfc415
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Tue May 7 20:56:17 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Tue May 7 20:56:17 2013 +0000

----------------------------------------------------------------------
 Allura/allura/ext/admin/admin_main.py              |    2 +-
 .../allura/ext/admin/templates/project_tools.html  |    4 ++--
 Allura/allura/lib/helpers.py                       |    7 ++++---
 Allura/allura/model/project.py                     |    2 ++
 Allura/allura/tests/test_helpers.py                |    8 ++++++--
 5 files changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/09bd5a74/Allura/allura/ext/admin/admin_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/admin_main.py b/Allura/allura/ext/admin/admin_main.py
index 34bc64c..433fade 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -559,7 +559,7 @@ class ProjectAdminController(BaseController):
                     sp.ordinal = int(new['ordinal'])
                 else:
                     require_access(c.project, 'admin')
-                    mount_point = new['mount_point'].lower() or ep_name.lower()
+                    mount_point = new['mount_point'] or ep_name
                     M.AuditLog.log('install tool %s', mount_point)
                     h.log_action(log, 'install tool').info(
                         'install tool %s', mount_point,

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/09bd5a74/Allura/allura/ext/admin/templates/project_tools.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/project_tools.html b/Allura/allura/ext/admin/templates/project_tools.html
index 0c8046d..e103ffe 100644
--- a/Allura/allura/ext/admin/templates/project_tools.html
+++ b/Allura/allura/ext/admin/templates/project_tools.html
@@ -54,7 +54,7 @@
       <small>
         * The mount point is the name of the tool as it will appear in a URL.
         <span class="mount-point-name-rules tool">
-          A valid mount point for this tool must begin with a letter, contain only letters,
+          A valid mount point for this tool must begin with a letter, contain only lowercase
letters,
           numbers, and dashes, and be from 1-63 characters in length.
         </span>
         <span class="mount-point-name-rules tool-relaxed">
@@ -63,7 +63,7 @@
           from 1-63 characters in length.
         </span>
         <span class="mount-point-name-rules subproject">
-          A valid subproject mount point must begin with a letter, contain only letters,
+          A valid subproject mount point must begin with a letter, contain only lowercase
letters,
           numbers, and dashes, and be from 3-15 characters in length.
         </span>
       </small>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/09bd5a74/Allura/allura/lib/helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index d55b511..c7b8fc6 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -60,8 +60,8 @@ re_project_name = re.compile(r'^[a-z][-a-z0-9]{2,14}$')
 # validates tool mount point names
 re_tool_mount_point = re.compile(r'^[a-z][-a-z0-9]{0,62}$')
 re_tool_mount_point_fragment = re.compile(r'[a-z][-a-z0-9]*')
-re_relaxed_tool_mount_point = re.compile(r'^[a-z0-9][-a-z0-9_\.\+]{0,62}$')
-re_relaxed_tool_mount_point_fragment = re.compile(r'[a-z0-9][-a-z0-9_\.\+]*')
+re_relaxed_tool_mount_point = re.compile(r'^[a-zA-Z0-9][-a-zA-Z0-9_\.\+]{0,62}$')
+re_relaxed_tool_mount_point_fragment = re.compile(r'[a-zA-Z0-9][-a-zA-Z0-9_\.\+]*')
 
 re_clean_vardec_key = re.compile(r'''\A
 ( # first part
@@ -90,7 +90,8 @@ def make_safe_path_portion(ustr, relaxed=True):
     ustr = really_unicode(ustr)
     s = ustr.encode('latin1', 'ignore')
     s = AsciiDammit.asciiDammit(s)
-    s = s.lower()
+    if not relaxed:
+        s = s.lower()
     s = '-'.join(regex.findall(s))
     s = s.replace('--', '-')
     return s

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/09bd5a74/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 39f1adb..da36ada 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -558,6 +558,8 @@ class Project(MappedClass, ActivityNode, ActivityObject):
             for x in range(10):
                 if self.app_instance(mount_point) is None: break
                 mount_point = base_mount_point + '-%d' % x
+        if not App.relaxed_mount_points:
+            mount_point = mount_point.lower()
         if not App.validate_mount_point(mount_point):
             raise exceptions.ToolError, 'Mount point "%s" is invalid' % mount_point
         # HACK: reserved url components

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/09bd5a74/Allura/allura/tests/test_helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_helpers.py b/Allura/allura/tests/test_helpers.py
index 40c0e96..6eb1719 100644
--- a/Allura/allura/tests/test_helpers.py
+++ b/Allura/allura/tests/test_helpers.py
@@ -41,11 +41,11 @@ class TestMakeSafePathPortion(TestCase):
         self.f = h.make_safe_path_portion
 
     def test_no_latin1_chars(self):
-        s = self.f(u'Задачи')
+        s = self.f(u'Задачи', relaxed=False)
         self.assertEqual(s, '')
 
     def test_some_latin1_chars(self):
-        s = self.f('åß∂ƒ')
+        s = self.f('åß∂ƒ', relaxed=False)
         self.assertEqual(s, 'ab')
 
     def test_strict_mount_point_names(self):
@@ -53,12 +53,16 @@ class TestMakeSafePathPortion(TestCase):
         self.assertEqual(s, 'this-is-illegal')
         s = self.f('this-1-is-legal', relaxed=False)
         self.assertEqual(s, 'this-1-is-legal')
+        s = self.f('THIS-IS-Illegal', relaxed=False)
+        self.assertEqual(s, 'this-is-illegal')
 
     def test_relaxed_mount_point_names(self):
         s = self.f('1_this+is.legal')
         self.assertEqual(s, '1_this+is.legal')
         s = self.f('not*_legal')
         self.assertEqual(s, 'not-legal')
+        s = self.f('THIS-IS-Illegal')
+        self.assertEqual(s, 'THIS-IS-Illegal')
 
 
 def test_really_unicode():


Mime
View raw message