allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [allura] 01/01: [#8296] fix handling of branch urls with / and ~ in them
Date Tue, 04 Jun 2019 20:34:52 GMT
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/8296
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 03927f7e4a81e1ded5c73a4d90101cabbd17dc4c
Author: Dave Brondsema <dave@brondsema.net>
AuthorDate: Tue Jun 4 16:23:00 2019 -0400

    [#8296] fix handling of branch urls with / and ~ in them
---
 Allura/allura/controllers/repository.py            |   8 +++---
 .../09/a2406097f0287c7b1789bb08368758cde3243a      |   5 ++++
 .../40/b807313e20151959fac47a7cb0438b7a89611e      | Bin 0 -> 51 bytes
 .../4e/7eadee735363b039e34ba79dfdb0fb8ea5a53a      | Bin 0 -> 26 bytes
 .../tests/data/test_branch.git/refs/heads/xyz/123  |   1 +
 .../data/test_branch.git/refs/tags/releases/v1.1.1 |   1 +
 .../forgegit/tests/functional/test_controllers.py  |  29 +++++++++++++++++++++
 7 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index c2b3ea8..0d08086 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -599,9 +599,9 @@ class RefsController(object):
 
     @expose()
     def _lookup(self, ref, *remainder):
-        EOR = quote(c.app.END_OF_REF_ESCAPE)
+        EOR = c.app.END_OF_REF_ESCAPE
         if EOR in remainder:
-            i = remainder.index(quote(c.app.END_OF_REF_ESCAPE))
+            i = remainder.index(EOR)
             ref = '/'.join((ref,) + remainder[:i])
             remainder = remainder[i + 1:]
         return self.BranchBrowserClass(ref), remainder
@@ -611,9 +611,9 @@ class CommitsController(object):
 
     @expose()
     def _lookup(self, ci, *remainder):
-        EOR = quote(c.app.END_OF_REF_ESCAPE)
+        EOR = c.app.END_OF_REF_ESCAPE
         if EOR in remainder:
-            i = remainder.index(quote(c.app.END_OF_REF_ESCAPE))
+            i = remainder.index(EOR)
             ci = '/'.join((ci,) + remainder[:i])
             remainder = remainder[i + 1:]
         return CommitBrowser(ci), remainder
diff --git a/ForgeGit/forgegit/tests/data/test_branch.git/objects/09/a2406097f0287c7b1789bb08368758cde3243a
b/ForgeGit/forgegit/tests/data/test_branch.git/objects/09/a2406097f0287c7b1789bb08368758cde3243a
new file mode 100644
index 0000000..e076d7e
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/test_branch.git/objects/09/a2406097f0287c7b1789bb08368758cde3243a
@@ -0,0 +1,5 @@
+x��M
+1@a�=E.�$��"i�2.��Z=�"x�����}�n��9D�`
+�5iY�,E+g���F��9DG$��C�_4V
+3EfC�C�����З����)~ε��K�2z+����s���d�����{
+�hU�NN�3W�C���T�G�
\ No newline at end of file
diff --git a/ForgeGit/forgegit/tests/data/test_branch.git/objects/40/b807313e20151959fac47a7cb0438b7a89611e
b/ForgeGit/forgegit/tests/data/test_branch.git/objects/40/b807313e20151959fac47a7cb0438b7a89611e
new file mode 100644
index 0000000..d61a3ea
Binary files /dev/null and b/ForgeGit/forgegit/tests/data/test_branch.git/objects/40/b807313e20151959fac47a7cb0438b7a89611e
differ
diff --git a/ForgeGit/forgegit/tests/data/test_branch.git/objects/4e/7eadee735363b039e34ba79dfdb0fb8ea5a53a
b/ForgeGit/forgegit/tests/data/test_branch.git/objects/4e/7eadee735363b039e34ba79dfdb0fb8ea5a53a
new file mode 100644
index 0000000..eea0ea9
Binary files /dev/null and b/ForgeGit/forgegit/tests/data/test_branch.git/objects/4e/7eadee735363b039e34ba79dfdb0fb8ea5a53a
differ
diff --git a/ForgeGit/forgegit/tests/data/test_branch.git/refs/heads/xyz/123 b/ForgeGit/forgegit/tests/data/test_branch.git/refs/heads/xyz/123
new file mode 100644
index 0000000..7101ea2
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/test_branch.git/refs/heads/xyz/123
@@ -0,0 +1 @@
+09a2406097f0287c7b1789bb08368758cde3243a
diff --git a/ForgeGit/forgegit/tests/data/test_branch.git/refs/tags/releases/v1.1.1 b/ForgeGit/forgegit/tests/data/test_branch.git/refs/tags/releases/v1.1.1
new file mode 100644
index 0000000..7101ea2
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/test_branch.git/refs/tags/releases/v1.1.1
@@ -0,0 +1 @@
+09a2406097f0287c7b1789bb08368758cde3243a
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index 46ebf2f..ffd0971 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -954,6 +954,35 @@ class TestGitBranch(TestController):
         assert 'README</a>' in r
         assert_equal(c.app.repo.get_default_branch('master'), 'test')
 
+    def test_branch_with_slashes(self):
+        branches_page = self.app.get('/src-git/ref/master/branches/')
+
+        r = branches_page.click('xyz/123', index=0)  # link in sidebar
+        assert r.request.url.endswith('src-git/ci/xyz/123/~/tree/'), r.request.url
+        r.mustcontain('on a branch')  # commit for this branch
+
+        r = branches_page.click('xyz/123', index=1)  # link in body
+        assert r.request.url.endswith('src-git/ci/xyz/123/~/tree/'), r.request.url
+        r.mustcontain('on a branch')  # commit for this branch
+
+    def test_ref_url_with_slashes(self):
+        r = self.app.get('/src-git/ref/xyz/123/~/')
+        assert r.location.endswith('src-git/ci/xyz/123/~/tree/')
+
+        r = self.app.get('/src-git/ref/xyz/123/~/log/')
+        assert r.location.endswith('src-git/ci/09a2406097f0287c7b1789bb08368758cde3243a/log/')
+
+    def test_tag_with_slashes(self):
+        tags_page = self.app.get('/src-git/ref/master/tags/')
+
+        r = tags_page.click('releases/v1.1.1', index=0)  # link in sidebar
+        assert r.request.url.endswith('src-git/ci/releases/v1.1.1/~/tree/'), r.request.url
+        r.mustcontain('on a branch')  # commit for this tag
+
+        r = tags_page.click('releases/v1.1.1', index=1)  # link in body
+        assert r.request.url.endswith('src-git/ci/releases/v1.1.1/~/tree/'), r.request.url
+        r.mustcontain('on a branch')  # commit for this tag
+
 
 class TestIncludeMacro(_TestCase):
     def setUp(self):


Mime
View raw message