From 16a9bdfd31d6e9df42b6604b84cc2aa42bb9ce5f Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Wed, 2 Aug 2017 17:09:31 +0530 Subject: [PATCH] Replaced urllib.unquote imports with six.moves.urllib.parse.unquote (#3836) --- frappe/core/doctype/file/file.py | 4 ++-- frappe/email/doctype/newsletter/test_newsletter.py | 2 +- frappe/oauth.py | 7 ++++--- frappe/sessions.py | 2 +- frappe/utils/file_manager.py | 4 ++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/frappe/core/doctype/file/file.py b/frappe/core/doctype/file/file.py index ddc54aafe3..f9b65e6556 100755 --- a/frappe/core/doctype/file/file.py +++ b/frappe/core/doctype/file/file.py @@ -10,7 +10,6 @@ naming for same name files: file.gif, file-1.gif, file-2.gif etc import frappe import json -import urllib import os import shutil import requests @@ -23,6 +22,7 @@ from frappe.utils.nestedset import NestedSet from frappe.utils import strip, get_files_path from PIL import Image, ImageOps from six import StringIO +from six.moves.urllib.parse import unquote import zipfile class FolderNotEmpty(frappe.ValidationError): pass @@ -383,7 +383,7 @@ def get_web_image(file_url): extn = None extn = get_extension(filename, extn, r.content) - filename = "/files/" + strip(urllib.unquote(filename)) + filename = "/files/" + strip(unquote(filename)) return image, filename, extn diff --git a/frappe/email/doctype/newsletter/test_newsletter.py b/frappe/email/doctype/newsletter/test_newsletter.py index a198037dc0..2b13799775 100644 --- a/frappe/email/doctype/newsletter/test_newsletter.py +++ b/frappe/email/doctype/newsletter/test_newsletter.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import frappe, unittest from frappe.email.doctype.newsletter.newsletter import confirmed_unsubscribe -from urllib import unquote +from six.moves.urllib.parse import unquote emails = ["test_subscriber1@example.com", "test_subscriber2@example.com", "test_subscriber3@example.com"] diff --git a/frappe/oauth.py b/frappe/oauth.py index 645a68e211..045f839f59 100644 --- a/frappe/oauth.py +++ b/frappe/oauth.py @@ -1,5 +1,5 @@ from __future__ import print_function -import frappe, urllib +import frappe import pytz from frappe import _ @@ -12,6 +12,7 @@ from oauthlib.oauth2.rfc6749.endpoints.token import TokenEndpoint from oauthlib.oauth2.rfc6749.endpoints.resource import ResourceEndpoint from oauthlib.oauth2.rfc6749.endpoints.revocation import RevocationEndpoint from oauthlib.common import Request +from six.moves.urllib.parse import unquote def get_url_delimiter(separator_character=" "): return separator_character @@ -134,7 +135,7 @@ class OAuthWebRequestValidator(RequestValidator): oac.scopes = get_url_delimiter().join(request.scopes) oac.redirect_uri_bound_to_authorization_code = request.redirect_uri oac.client = client_id - oac.user = urllib.unquote(cookie_dict['user_id']) + oac.user = unquote(cookie_dict['user_id']) oac.authorization_code = code['code'] oac.save(ignore_permissions=True) frappe.db.commit() @@ -159,7 +160,7 @@ class OAuthWebRequestValidator(RequestValidator): except Exception as e: print("Failed body authentication: Application %s does not exist".format(cid=request.client_id)) - return frappe.session.user == urllib.unquote(cookie_dict.get('user_id', "Guest")) + return frappe.session.user == unquote(cookie_dict.get('user_id', "Guest")) def authenticate_client_id(self, client_id, request, *args, **kwargs): cli_id = frappe.db.get_value('OAuth Client', client_id, 'name') diff --git a/frappe/sessions.py b/frappe/sessions.py index 52c849ae7a..37f26921f0 100644 --- a/frappe/sessions.py +++ b/frappe/sessions.py @@ -17,7 +17,7 @@ import frappe.defaults import frappe.translate from frappe.utils.change_log import get_change_log import redis -from urllib import unquote +from six.moves.urllib.parse import unquote from frappe.desk.notifications import clear_notifications from six import text_type diff --git a/frappe/utils/file_manager.py b/frappe/utils/file_manager.py index 56a03abb29..2d32215d6a 100644 --- a/frappe/utils/file_manager.py +++ b/frappe/utils/file_manager.py @@ -10,7 +10,7 @@ from frappe.utils import get_hook_method, get_files_path, random_string, encode, from frappe import _ from frappe import conf from copy import copy -import urllib +from six.moves.urllib.parse import unquote from six import text_type class MaxFileSizeReachedError(frappe.ValidationError): pass @@ -67,7 +67,7 @@ def save_url(file_url, filename, dt, dn, folder, is_private): # frappe.msgprint("URL must start with 'http://' or 'https://'") # return None, None - file_url = urllib.unquote(file_url) + file_url = unquote(file_url) f = frappe.get_doc({ "doctype": "File",