You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2023/12/05 20:44:30 UTC
(allura) branch db/8529 created (now bb431c442)
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a change to branch db/8529
in repository https://gitbox.apache.org/repos/asf/allura.git
at bb431c442 [#8529] fix repo root and /ref/ controller to handle unicode branch names
This branch includes the following new commits:
new bb431c442 [#8529] fix repo root and /ref/ controller to handle unicode branch names
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(allura) 01/01: [#8529] fix repo root and /ref/ controller to handle unicode branch names
Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch db/8529
in repository https://gitbox.apache.org/repos/asf/allura.git
commit bb431c44260c945d700d1d81bbda90e4486a11f9
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Tue Dec 5 15:44:02 2023 -0500
[#8529] fix repo root and /ref/ controller to handle unicode branch names
---
Allura/allura/controllers/repository.py | 3 ++-
ForgeGit/forgegit/controllers.py | 3 ++-
ForgeGit/forgegit/tests/functional/test_controllers.py | 6 ++++++
ForgeSVN/forgesvn/controllers.py | 4 ++--
4 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 224e5decf..351d3642f 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -91,7 +91,7 @@ class RepoRootController(BaseController, FeedController):
def index(self, offset=0, branch=None, **kw):
if branch is None:
branch = c.app.default_branch_name
- permanent_redirect(c.app.repo.url_for_commit(branch, url_type='ref'))
+ permanent_redirect(h.urlquote(c.app.repo.url_for_commit(branch, url_type='ref')))
@with_trailing_slash
@expose('jinja:allura:templates/repo/forks.html')
@@ -628,6 +628,7 @@ class RefsController:
def _lookup(self, ref=None, *remainder):
if ref is None:
raise exc.HTTPNotFound
+ ref = unquote(ref)
EOR = c.app.END_OF_REF_ESCAPE
if EOR in remainder:
i = remainder.index(EOR)
diff --git a/ForgeGit/forgegit/controllers.py b/ForgeGit/forgegit/controllers.py
index 0c504e935..2062d0c24 100644
--- a/ForgeGit/forgegit/controllers.py
+++ b/ForgeGit/forgegit/controllers.py
@@ -21,6 +21,7 @@ from tg import expose, redirect
from tg.decorators import with_trailing_slash
from tg import tmpl_context as c
+from allura.lib import helpers as h
from allura.controllers import repository
@@ -33,4 +34,4 @@ class BranchBrowser(repository.BranchBrowser):
latest = c.app.repo.latest(branch=self._branch)
if is_empty or not latest:
return dict(allow_fork=False, log=[], is_empty=is_empty)
- permanent_redirect(c.app.repo.url_for_commit(self._branch) + 'tree/')
+ permanent_redirect(h.urlquote(c.app.repo.url_for_commit(self._branch) + 'tree/'))
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index cb5c7bba7..3d994ca4f 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -525,6 +525,12 @@ class TestRootController(_TestCase):
assert 'bad</a>' not in r
assert 'README</a>' in r
+ def test_index_branch_unicode(self):
+ # more realistic case is the default branch having unicode, but passing the branch name is easier
+ resp = self.app.get('/p/test/src-git/', params={'branch':'ƒ∂ß'})
+ assert resp.location == 'http://localhost/p/test/src-git/ref/%C6%92%E2%88%82%C3%9F/'
+ # further testing needs a real branch in our test repo
+
def test_set_checkout_url(self):
r = self.app.get('/p/test/admin/src-git/checkout_url')
r.form['external_checkout_url'].value = 'http://foo.bar/baz'
diff --git a/ForgeSVN/forgesvn/controllers.py b/ForgeSVN/forgesvn/controllers.py
index cf10c2ee9..ac07d05a5 100644
--- a/ForgeSVN/forgesvn/controllers.py
+++ b/ForgeSVN/forgesvn/controllers.py
@@ -21,6 +21,7 @@ from tg import expose, redirect
from tg.decorators import with_trailing_slash
from tg import tmpl_context as c
+from allura.lib import helpers as h
from allura.controllers import repository
from allura.controllers.feed import FeedController
@@ -40,8 +41,7 @@ class BranchBrowser(repository.BranchBrowser, FeedController):
latest = c.app.repo.latest(branch=self._branch)
if is_empty or not latest:
return dict(allow_fork=False, log=[], is_empty=is_empty)
- permanent_redirect(c.app.repo.url_for_commit(c.app.default_branch_name)
- + 'tree/')
+ permanent_redirect(h.urlquote(c.app.repo.url_for_commit(c.app.default_branch_name) + 'tree/'))
@expose()
def _lookup(self, rev, *remainder):