-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix regression in storage url signing of objects with slashes in names #1348
Conversation
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
@mickeyreiss this should fix the regression, feel free to comment on :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - assuming my questions are incorrect.
@@ -528,7 +528,8 @@ public URL signUrl(BlobInfo blobInfo, long duration, TimeUnit unit, SignUrlOptio | |||
if (blobInfo.getName().startsWith("/")) { | |||
path.setLength(path.length() - 1); | |||
} | |||
path.append(UrlEscapers.urlPathSegmentEscaper().escape(blobInfo.getName())); | |||
String escapedName = UrlEscapers.urlFragmentEscaper().escape(blobInfo.getName()); | |||
path.append(escapedName.replace("?", "%3F")); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -1323,7 +1323,8 @@ public void testSignUrlForBlobWithSpecialChars() throws NoSuchAlgorithmException | |||
String blobName = "/a" + specialChar + "b"; | |||
URL url = | |||
storage.signUrl(BlobInfo.newBuilder(BUCKET_NAME1, blobName).build(), 14, TimeUnit.DAYS); | |||
String escapedBlobName = UrlEscapers.urlPathSegmentEscaper().escape(blobName); | |||
String escapedBlobName = | |||
UrlEscapers.urlFragmentEscaper().escape(blobName).replace("?", "%3F"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -1193,7 +1193,7 @@ public void testWriteChannelExistingBlob() throws IOException { | |||
|
|||
@Test | |||
public void testGetSignedUrl() throws IOException { | |||
String blobName = "test-get-signed-url-blob"; | |||
String blobName = "test-get-signed-url-blob/with/slashes/and?special=char*"; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Thanks for the admirably fast turnaround!
@@ -1323,7 +1323,8 @@ public void testSignUrlForBlobWithSpecialChars() throws NoSuchAlgorithmException | |||
String blobName = "/a" + specialChar + "b"; | |||
URL url = | |||
storage.signUrl(BlobInfo.newBuilder(BUCKET_NAME1, blobName).build(), 14, TimeUnit.DAYS); | |||
String escapedBlobName = UrlEscapers.urlPathSegmentEscaper().escape(blobName); | |||
String escapedBlobName = | |||
UrlEscapers.urlFragmentEscaper().escape(blobName).replace("?", "%3F"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
LGTM |
This replaces #1347 and fixes #1346
@ostronom I took the liberty to cherry-pick your commits and apply some fixes, namely:
?
character:UrlEscapers.urlFragmentEscaper()
does not escape?
. Even though the use of?
in blob names is discouraged (see here) we better handle it properlysignUrl
integration tests@ostronom @lesv can you have a look?