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 2019/03/04 16:00:30 UTC

[allura] 01/02: [#8269] make external link redirects use 302 since the URL could change

This is an automated email from the ASF dual-hosted git repository.

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

commit b49989d3f1bd230f1e2b174370a2567cf3e5df14
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Fri Mar 1 17:55:04 2019 -0500

    [#8269] make external link redirects use 302 since the URL could change
---
 ForgeLink/forgelink/link_main.py                  | 7 +++----
 ForgeLink/forgelink/tests/functional/test_root.py | 8 ++++----
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/ForgeLink/forgelink/link_main.py b/ForgeLink/forgelink/link_main.py
index 07238f1..43a4624 100644
--- a/ForgeLink/forgelink/link_main.py
+++ b/ForgeLink/forgelink/link_main.py
@@ -20,7 +20,7 @@ import logging
 import json
 
 # Non-stdlib imports
-from tg import expose, jsonify
+from tg import expose, jsonify, redirect
 from pylons import tmpl_context as c
 from pylons import request
 from formencode import validators as fev
@@ -29,7 +29,6 @@ from formencode import validators as fev
 from allura.app import Application, ConfigOption, SitemapEntry
 from allura.lib import helpers as h
 from allura.lib.security import require_access
-from allura.lib.utils import permanent_redirect
 from allura import model as M
 from allura.controllers import BaseController
 from allura.controllers.rest import AppRestControllerMixin
@@ -121,7 +120,7 @@ class RootController(BaseController):
     def index(self, **kw):
         url = c.app.config.options.get('url')
         if url:
-            permanent_redirect(url)
+            redirect(url)
         return dict()
 
     @expose()
@@ -129,7 +128,7 @@ class RootController(BaseController):
         path = "/".join(remainder)
         url = c.app.config.options.get('url')
         if url:
-            permanent_redirect(url + h.really_unicode(path).encode('utf-8'))
+            redirect(url + h.really_unicode(path).encode('utf-8'))
         return dict()
 
 
diff --git a/ForgeLink/forgelink/tests/functional/test_root.py b/ForgeLink/forgelink/tests/functional/test_root.py
index 6235707..f0fe1fd 100644
--- a/ForgeLink/forgelink/tests/functional/test_root.py
+++ b/ForgeLink/forgelink/tests/functional/test_root.py
@@ -34,7 +34,7 @@ class TestRootController(TestController):
         response = self.app.get('/admin/link/options', validate_chunk=True)
         response.form['url'] = 'http://www.google.com/'
         response.form.submit()
-        redir = self.app.get('/link/index', status=301)
+        redir = self.app.get('/link/index', status=302)
         assert_equal(redir.location, 'http://www.google.com/')
 
     @td.with_link
@@ -42,7 +42,7 @@ class TestRootController(TestController):
         response = self.app.get('/admin/link/options', validate_chunk=True)
         response.form['url'] = 'http://www.google.com/'
         response.form.submit()
-        redir = self.app.get('/link', status=301)
+        redir = self.app.get('/link', status=302)
         assert_equal(redir.location, 'http://www.google.com/')
 
     @td.with_link
@@ -50,7 +50,7 @@ class TestRootController(TestController):
         response = self.app.get('/admin/link/options', validate_chunk=True)
         response.form['url'] = 'http://www.google.com/'
         response.form.submit()
-        redir = self.app.get('/link/service', status=301)
+        redir = self.app.get('/link/service', status=302)
         assert_equal(redir.location, 'http://www.google.com/service')
 
     @td.with_link
@@ -58,7 +58,7 @@ class TestRootController(TestController):
         response = self.app.get('/admin/link/options', validate_chunk=True)
         response.form['url'] = 'http://www.google.de/search?q='
         response.form.submit()
-        redir = self.app.get('/link/help', status=301)
+        redir = self.app.get('/link/help', status=302)
         assert_equal(redir.location, 'http://www.google.de/search?q=help')