From 499a40baf7449c77ad7304acf29fae1c40829771 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Mon, 21 Jan 2019 12:23:23 +0100 Subject: [PATCH] Update for new module/namespace for urllib --- pgweb/account/views.py | 8 ++++---- pgweb/core/views.py | 4 ++-- pgweb/search/views.py | 8 ++++---- tools/communityauth/test_auth.py | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pgweb/account/views.py b/pgweb/account/views.py index 9a67afa4..794165c2 100644 --- a/pgweb/account/views.py +++ b/pgweb/account/views.py @@ -13,7 +13,7 @@ from django.db import transaction from django.db.models import Q import base64 -import urllib +import urllib.parse from Crypto.Cipher import AES from Crypto import Random import time @@ -470,7 +470,7 @@ def communityauth(request, siteid): # care that it's characters are what's in base64. if 'd' in request.GET: d = request.GET['d'] - if d != urllib.quote_plus(d, '=$'): + if d != urllib.parse.quote_plus(d, '=$'): # Invalid character, so drop it d = None else: @@ -525,7 +525,7 @@ def communityauth(request, siteid): if site.org.require_consent: if not CommunityAuthConsent.objects.filter(org=site.org, user=request.user).exists(): return HttpResponseRedirect('/account/auth/{0}/consent/?{1}'.format(siteid, - urllib.urlencode({'next': '/account/auth/{0}/{1}'.format(siteid, urldata)}))) + urllib.parse.urlencode({'next': '/account/auth/{0}/{1}'.format(siteid, urldata)}))) info = { 'u': request.user.username.encode('utf-8'), @@ -540,7 +540,7 @@ def communityauth(request, siteid): # Turn this into an URL. Make sure the timestamp is always first, that makes # the first block more random.. - s = "t=%s&%s" % (int(time.time()), urllib.urlencode(info)) + s = "t=%s&%s" % (int(time.time()), urllib.parse.urlencode(info)) # Encrypt it with the shared key (and IV!) r = Random.new() diff --git a/pgweb/core/views.py b/pgweb/core/views.py index 4ec07709..6e256f1f 100644 --- a/pgweb/core/views.py +++ b/pgweb/core/views.py @@ -15,7 +15,7 @@ import django from datetime import date, datetime, timedelta import os import re -import urllib +import urllib.parse from pgweb.util.decorators import cache, nocache from pgweb.util.contexts import render_pgweb, get_nav_menu, PGWebContextProcessor @@ -165,7 +165,7 @@ def _make_sitemap(pagelist): for p in pagelist: pages += 1 x.startElement('url', {}) - x.add_xml_element('loc', 'https://www.postgresql.org/%s' % urllib.quote(p[0])) + x.add_xml_element('loc', 'https://www.postgresql.org/%s' % urllib.parse.quote(p[0])) if len(p) > 1 and p[1]: x.add_xml_element('priority', str(p[1])) if len(p) > 2 and p[2]: diff --git a/pgweb/search/views.py b/pgweb/search/views.py index 677f05e2..2eb93fec 100644 --- a/pgweb/search/views.py +++ b/pgweb/search/views.py @@ -161,7 +161,7 @@ def search(request): p['ln'] = MailingList.objects.get(pk=listid).listname if dateval: p['d'] = dateval - urlstr = urllib.urlencode(p) + urlstr = urllib.parse.urlencode(p) # If memcached is available, let's try it hits = None if has_memcached: @@ -212,7 +212,7 @@ def search(request): totalhits = len(hits) querystr = "?m=1&q=%s&l=%s&d=%s&s=%s" % ( - urllib.quote_plus(query.encode('utf-8')), + urllib.parse.quote_plus(query.encode('utf-8')), listid or '', dateval, listsort @@ -281,13 +281,13 @@ def search(request): totalhits = int(hits[-1][5]) try: if suburl: - quoted_suburl = urllib.quote_plus(suburl) + quoted_suburl = urllib.parse.quote_plus(suburl) else: quoted_suburl = '' except: quoted_suburl = '' querystr = "?q=%s&a=%s&u=%s" % ( - urllib.quote_plus(query.encode('utf-8')), + urllib.parse.quote_plus(query.encode('utf-8')), allsites and "1" or "0", quoted_suburl, ) diff --git a/tools/communityauth/test_auth.py b/tools/communityauth/test_auth.py index 9d944999..19106fd5 100755 --- a/tools/communityauth/test_auth.py +++ b/tools/communityauth/test_auth.py @@ -10,7 +10,7 @@ from Crypto import Random from Crypto.Cipher import AES import base64 import time -import urllib +import urllib.parse from optparse import OptionParser -- 2.11.4.GIT