allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [allura] 12/16: [#8375] url quoting fixes
Date Thu, 27 Aug 2020 20:35:37 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 745601001484d372261e602eb5cdf115e8389958
Author: Dave Brondsema <dave@brondsema.net>
AuthorDate: Wed Aug 26 12:55:22 2020 -0400

    [#8375] url quoting fixes
---
 ForgeLink/forgelink/link_main.py                  |  2 +-
 ForgeLink/forgelink/tests/functional/test_rest.py | 14 +++++++-------
 ForgeLink/forgelink/tests/functional/test_root.py |  6 ++++--
 ForgeWiki/forgewiki/tests/functional/test_rest.py |  4 ++--
 4 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/ForgeLink/forgelink/link_main.py b/ForgeLink/forgelink/link_main.py
index ef2dcb0..964ea24 100644
--- a/ForgeLink/forgelink/link_main.py
+++ b/ForgeLink/forgelink/link_main.py
@@ -135,7 +135,7 @@ class RootController(BaseController):
         if url:
             # h.urlquote is better than utf8 encoding for Location headers, but in this case
the url can be a full
             # http://... url and we don't want to urlquote/urlencode that part
-            redirect(url + h.really_unicode(path).encode('utf-8'))
+            redirect(url + h.really_unicode(path))
         return dict()
 
 
diff --git a/ForgeLink/forgelink/tests/functional/test_rest.py b/ForgeLink/forgelink/tests/functional/test_rest.py
index 7d5c419..c93f2c5 100644
--- a/ForgeLink/forgelink/tests/functional/test_rest.py
+++ b/ForgeLink/forgelink/tests/functional/test_rest.py
@@ -37,20 +37,20 @@ class TestLinkApi(TestRestApiBase):
         h.set_context('test', 'link', neighborhood='Projects')
 
     def test_rest_link(self):
-        r = self.api_get('/rest/p/test/link'.encode('utf-8'))
+        r = self.api_get('/rest/p/test/link')
         assert_equal(r.json['url'], None)
 
-        r = self.api_post('/rest/p/test/link'.encode('utf-8'),
+        r = self.api_post('/rest/p/test/link',
                           url='http://google.com')
         assert_equal(r.json['url'], 'http://google.com')
 
-        self.api_post('/rest/p/test/link'.encode('utf-8'),
+        self.api_post('/rest/p/test/link',
                       url='http://yahoo.com')
-        r = self.api_get('/rest/p/test/link'.encode('utf-8'))
+        r = self.api_get('/rest/p/test/link')
         assert_equal(r.json['url'], 'http://yahoo.com')
 
-        self.api_post('/rest/p/test/link'.encode('utf-8'))
-        r = self.api_get('/rest/p/test/link'.encode('utf-8'))
+        self.api_post('/rest/p/test/link')
+        r = self.api_get('/rest/p/test/link')
         assert_equal(r.json['url'], 'http://yahoo.com')
 
     def test_rest_link_get_permissions(self):
@@ -78,7 +78,7 @@ class TestLinkApi(TestRestApiBase):
                       params={'url': 'http://yahoo.com'},
                       extra_environ={'username': str('*anonymous')},
                       status=200)
-        r = self.api_get('/rest/p/test/link'.encode('utf-8'))
+        r = self.api_get('/rest/p/test/link')
         assert_equal(r.json['url'], 'http://yahoo.com')
 
 
diff --git a/ForgeLink/forgelink/tests/functional/test_root.py b/ForgeLink/forgelink/tests/functional/test_root.py
index 527178a..fe2f1c3 100644
--- a/ForgeLink/forgelink/tests/functional/test_root.py
+++ b/ForgeLink/forgelink/tests/functional/test_root.py
@@ -1,3 +1,4 @@
+# coding=utf-8
 #       Licensed to the Apache Software Foundation (ASF) under one
 #       or more contributor license agreements.  See the NOTICE file
 #       distributed with this work for additional information
@@ -22,6 +23,7 @@ import json
 from nose.tools import assert_equal, assert_in
 
 from allura import model as M
+from allura.lib import helpers as h
 from allura.tests import decorators as td
 from alluratest.controller import TestController
 
@@ -61,8 +63,8 @@ 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=302)
-        assert_equal(redir.location, 'http://www.google.de/search?q=help')
+        redir = self.app.get(h.urlquote('/link/helpåß'), status=302)
+        assert_equal(redir.location, 'http://www.google.de/search?q=help%C3%A5%C3%9F')
 
 
 class TestConfigOptions(TestController):
diff --git a/ForgeWiki/forgewiki/tests/functional/test_rest.py b/ForgeWiki/forgewiki/tests/functional/test_rest.py
index 44b697f..e15f90f 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_rest.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_rest.py
@@ -85,9 +85,9 @@ class TestWikiApi(TestRestApiBase):
             'text': 'Embrace the Dark Side',
             'labels': 'head hunting,dark side'
         }
-        r = self.api_post('/rest/p/test/wiki/tést/'.encode('utf-8'), **data)
+        r = self.api_post(h.urlquote('/rest/p/test/wiki/tést/'), **data)
         assert_equal(r.status_int, 200)
-        r = self.api_get('/rest/p/test/wiki/tést/'.encode('utf-8'))
+        r = self.api_get(h.urlquote('/rest/p/test/wiki/tést/'))
         assert_equal(r.json['text'], data['text'])
         assert_equal(r.json['labels'], data['labels'].split(','))
 


Mime
View raw message