You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by gc...@apache.org on 2022/04/05 20:55:38 UTC
[allura] 01/02: [#8424] better error handling for Wiki browse_pages and Discussion threads
This is an automated email from the ASF dual-hosted git repository.
gcruz pushed a commit to branch gc/8424
in repository https://gitbox.apache.org/repos/asf/allura.git
commit e9892a290fcb984f4c2927de52a8fad6d60d6c2c
Author: Guillermo Cruz <gu...@slashdotmedia.com>
AuthorDate: Tue Apr 5 12:05:43 2022 -0600
[#8424] better error handling for Wiki browse_pages and Discussion threads
---
Allura/allura/controllers/discuss.py | 5 +++--
ForgeWiki/forgewiki/wiki_main.py | 9 +++++++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index ddaf61b64..a22c7a36a 100644
--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-from six.moves.urllib.parse import unquote
+from six.moves.urllib.parse import unquote, urlsplit, parse_qs
from datetime import datetime
import logging
@@ -189,7 +189,8 @@ class ThreadController(BaseController, FeedController, metaclass=h.ProxiedAttrMe
self.discussion = discussion_controller.discussion
self.thread = self.M.Thread.query.get(_id=thread_id)
if not self.thread:
- raise exc.HTTPNotFound
+ url = '/p/{}/discussion/{}/'.format(c.project.shortname, c.forum.shortname)
+ utils.permanent_redirect(url)
@expose()
def _lookup(self, id, *remainder):
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 180d3ea1d..2e48c7728 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -21,7 +21,7 @@ import os
from pprint import pformat
import six
-from six.moves.urllib.parse import unquote
+from six.moves.urllib.parse import unquote, urlencode
# Non-stdlib imports
from tg import expose, validate, redirect, flash, jsonify
@@ -400,6 +400,10 @@ class RootController(BaseController, DispatchIndex, FeedController):
def __init__(self):
self._discuss = AppDiscussionController()
+ def catch_all(self, *args, **kw):
+ url = '/{}/?{}'.format(request.controller_url, urlencode(kw))
+ redirect(h.urlquote(h.really_unicode(url)))
+
def _check_security(self):
require_access(c.app, 'read')
@@ -444,7 +448,8 @@ class RootController(BaseController, DispatchIndex, FeedController):
@validate(dict(sort=v.UnicodeString(if_empty='alpha'),
show_deleted=validators.StringBool(if_empty=False),
page=validators.Int(if_empty=0, if_invalid=0),
- limit=validators.Int(if_empty=None, if_invalid=None)))
+ limit=validators.Int(if_empty=None, if_invalid=None)),
+ error_handler=catch_all)
def browse_pages(self, sort='alpha', show_deleted=False, page=0, limit=None, **kw):
'list of all pages in the wiki'
c.page_list = W.page_list