Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5e0d4cf

Browse filesBrowse files
houglumfrankyn
authored andcommitted
Fix encoding of object names. (GoogleCloudPlatform#2473)
Per the docs, the "/" character should not be escaped in the object name portion of the signed URL. Also, Python 2 and 3 differ on whether the tilde character should be escaped by the url library's `quote` method, so in order for our sample to work on both Python2 and Python3, we should always specify the tilde as a "safe" character. For reference, we already fixed this same bug in gsutil a few months ago: https://github.com/GoogleCloudPlatform/gsutil/blob/4531874e3a3d45ca642fc9c9fa438ba58c8f1494/gslib/commands/signurl.py#L543
1 parent e2923f5 commit 5e0d4cf
Copy full SHA for 5e0d4cf

File tree

Expand file treeCollapse file tree

1 file changed

+2
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-1
lines changed

‎storage/signed_urls/generate_signed_urls.py

Copy file name to clipboardExpand all lines: storage/signed_urls/generate_signed_urls.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import sys
3131

3232
# pip install six
33+
import six
3334
from six.moves.urllib.parse import quote
3435

3536
# [START storage_signed_url_signer]
@@ -49,7 +50,7 @@ def generate_signed_url(service_account_file, bucket_name, object_name,
4950
sys.exit(1)
5051

5152
# [START storage_signed_url_canonical_uri]
52-
escaped_object_name = quote(object_name, safe='')
53+
escaped_object_name = quote(six.ensure_binary(object_name), safe=b'/~')
5354
canonical_uri = '/{}/{}'.format(bucket_name, escaped_object_name)
5455
# [END storage_signed_url_canonical_uri]
5556

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.