Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change url quoting in boto3 to use python urllib quote #601

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions storages/backends/s3boto3.py
Expand Up @@ -13,7 +13,7 @@
from django.core.files.storage import Storage
from django.utils.deconstruct import deconstructible
from django.utils.encoding import (
filepath_to_uri, force_bytes, force_text, smart_text,
force_bytes, force_text, smart_text,
)
from django.utils.six.moves.urllib import parse as urlparse
from django.utils.timezone import is_naive, localtime
Expand Down Expand Up @@ -612,7 +612,7 @@ def url(self, name, parameters=None, expire=None):
name = self._normalize_name(self._clean_name(name))
if self.custom_domain:
return "%s//%s/%s" % (self.url_protocol,
self.custom_domain, filepath_to_uri(name))
self.custom_domain, urlparse.quote(name))
if expire is None:
expire = self.querystring_expire

Expand Down
4 changes: 2 additions & 2 deletions tests/test_s3boto3.py
Expand Up @@ -507,11 +507,11 @@ def test_storage_url(self):

def test_generated_url_is_encoded(self):
self.storage.custom_domain = "mock.cloudfront.net"
filename = "whacky & filename.mp4"
filename = "whacky & filename'.mp4"
url = self.storage.url(filename)
parsed_url = urlparse.urlparse(url)
self.assertEqual(parsed_url.path,
"/whacky%20%26%20filename.mp4")
"/whacky%20%26%20filename%27.mp4")
self.assertFalse(self.storage.bucket.meta.client.generate_presigned_url.called)

def test_special_characters(self):
Expand Down