-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Added UTF-8 encoding for blob names in methods that are used to build… #5943
Changes from all commits
9230cc1
6b94186
a665c1a
1227465
55ac267
b18fbed
009d5ab
995e411
aa04de2
4b527de
9bcd0a0
2172d80
6489555
dfb9416
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
import com.azure.storage.blob.models.AccessTier; | ||
import com.azure.storage.blob.models.BlobRequestConditions; | ||
import com.azure.storage.blob.models.DeleteSnapshotsOptionType; | ||
import com.azure.storage.common.Utility; | ||
import com.azure.storage.common.policy.StorageSharedKeyCredentialPolicy; | ||
import reactor.core.Disposable; | ||
import reactor.core.Exceptions; | ||
|
@@ -136,7 +137,8 @@ public final class BlobBatch { | |
* @throws UnsupportedOperationException If this batch has already added an operation of another type. | ||
*/ | ||
public Response<Void> deleteBlob(String containerName, String blobName) { | ||
return deleteBlobHelper(String.format(PATH_TEMPLATE, containerName, blobName), null, null); | ||
return deleteBlobHelper(String.format(PATH_TEMPLATE, containerName, | ||
Utility.urlEncode(Utility.urlDecode(blobName))), null, null); | ||
} | ||
|
||
/** | ||
|
@@ -156,8 +158,8 @@ public Response<Void> deleteBlob(String containerName, String blobName) { | |
*/ | ||
public Response<Void> deleteBlob(String containerName, String blobName, | ||
DeleteSnapshotsOptionType deleteOptions, BlobRequestConditions blobRequestConditions) { | ||
return deleteBlobHelper(String.format(PATH_TEMPLATE, containerName, blobName), | ||
deleteOptions, blobRequestConditions); | ||
return deleteBlobHelper(String.format(PATH_TEMPLATE, containerName, | ||
Utility.urlEncode(Utility.urlDecode(blobName))), deleteOptions, blobRequestConditions); | ||
} | ||
|
||
/** | ||
|
@@ -167,7 +169,7 @@ public Response<Void> deleteBlob(String containerName, String blobName, | |
* | ||
* {@codesnippet com.azure.storage.blob.batch.BlobBatch.deleteBlob#String} | ||
* | ||
* @param blobUrl URL of the blob. | ||
* @param blobUrl URL of the blob. Blob name must be encoded to UTF-8. | ||
* @return a {@link Response} that will be used to associate this operation to the response when the batch is | ||
* submitted. | ||
* @throws UnsupportedOperationException If this batch has already added an operation of another type. | ||
|
@@ -183,7 +185,7 @@ public Response<Void> deleteBlob(String blobUrl) { | |
* | ||
* {@codesnippet com.azure.storage.blob.batch.BlobBatch.deleteBlob#String-DeleteSnapshotsOptionType-BlobRequestConditions} | ||
* | ||
* @param blobUrl URL of the blob. | ||
* @param blobUrl URL of the blob. Blob name must be encoded to UTF-8. | ||
* @param deleteOptions Delete options for the blob and its snapshots. | ||
* @param blobRequestConditions Additional access conditions that must be met to allow this operation. | ||
* @return a {@link Response} that will be used to associate this operation to the response when the batch is | ||
|
@@ -217,7 +219,8 @@ private Response<Void> deleteBlobHelper(String urlPath, DeleteSnapshotsOptionTyp | |
* @throws UnsupportedOperationException If this batch has already added an operation of another type. | ||
*/ | ||
public Response<Void> setBlobAccessTier(String containerName, String blobName, AccessTier accessTier) { | ||
return setBlobAccessTierHelper(String.format(PATH_TEMPLATE, containerName, blobName), accessTier, null); | ||
return setBlobAccessTierHelper(String.format(PATH_TEMPLATE, containerName, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment about calling the next overload. |
||
Utility.urlEncode(Utility.urlDecode(blobName))), accessTier, null); | ||
} | ||
|
||
/** | ||
|
@@ -237,7 +240,8 @@ public Response<Void> setBlobAccessTier(String containerName, String blobName, A | |
*/ | ||
public Response<Void> setBlobAccessTier(String containerName, String blobName, AccessTier accessTier, | ||
String leaseId) { | ||
return setBlobAccessTierHelper(String.format(PATH_TEMPLATE, containerName, blobName), accessTier, leaseId); | ||
return setBlobAccessTierHelper(String.format(PATH_TEMPLATE, containerName, | ||
Utility.urlEncode(Utility.urlDecode(blobName))), accessTier, leaseId); | ||
} | ||
|
||
/** | ||
|
@@ -247,7 +251,7 @@ public Response<Void> setBlobAccessTier(String containerName, String blobName, A | |
* | ||
* {@codesnippet com.azure.storage.blob.batch.BlobBatch.setBlobAccessTier#String-AccessTier} | ||
* | ||
* @param blobUrl URL of the blob. | ||
* @param blobUrl URL of the blob. Blob name must be encoded to UTF-8. | ||
* @param accessTier The tier to set on the blob. | ||
* @return a {@link Response} that will be used to associate this operation to the response when the batch is | ||
* submitted. | ||
|
@@ -264,7 +268,7 @@ public Response<Void> setBlobAccessTier(String blobUrl, AccessTier accessTier) { | |
* | ||
* {@codesnippet com.azure.storage.blob.batch.BlobBatch.setBlobAccessTier#String-AccessTier-String} | ||
* | ||
* @param blobUrl URL of the blob. | ||
* @param blobUrl URL of the blob. Blob name must be encoded to UTF-8. | ||
* @param accessTier The tier to set on the blob. | ||
* @param leaseId The lease ID the active lease on the blob must match. | ||
* @return a {@link Response} that will be used to associate this operation to the response when the batch is | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,12 +127,12 @@ public BlobUrlParts setContainerName(String containerName) { | |
} | ||
|
||
/** | ||
* Gets the blob name that will be used as part of the URL path. | ||
* Decodes and gets the blob name that will be used as part of the URL path. | ||
* | ||
* @return the blob name. | ||
* @return the decoded blob name. | ||
*/ | ||
public String getBlobName() { | ||
return blobName; | ||
return (blobName == null) ? null : Utility.urlDecode(blobName); | ||
} | ||
|
||
/** | ||
|
@@ -142,7 +142,7 @@ public String getBlobName() { | |
* @return the updated BlobUrlParts object. | ||
*/ | ||
public BlobUrlParts setBlobName(String blobName) { | ||
this.blobName = blobName; | ||
this.blobName = Utility.urlEncode(Utility.urlDecode(blobName)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Overload to skip encoding? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See answer about overloads and double encoding above. |
||
return this; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
import com.azure.storage.blob.models.RehydratePriority; | ||
import com.azure.storage.blob.models.ReliableDownloadOptions; | ||
import com.azure.storage.blob.models.StorageAccountInfo; | ||
import com.azure.storage.common.Utility; | ||
import com.azure.storage.common.implementation.Constants; | ||
import com.azure.storage.common.implementation.StorageImplUtils; | ||
import reactor.core.publisher.Flux; | ||
|
@@ -113,7 +114,7 @@ protected BlobAsyncClientBase(HttpPipeline pipeline, String url, BlobServiceVers | |
|
||
this.accountName = accountName; | ||
this.containerName = containerName; | ||
this.blobName = blobName; | ||
this.blobName = Utility.urlEncode(Utility.urlDecode(blobName)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we encode in the builder, so encoding in the constructor again would be double encoding? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See answer about overloads and double encoding above. |
||
this.snapshot = snapshot; | ||
this.customerProvidedKey = customerProvidedKey; | ||
} | ||
|
@@ -160,16 +161,16 @@ public final String getContainerName() { | |
} | ||
|
||
/** | ||
* Get the blob name. | ||
* Decodes and gets the blob name. | ||
* | ||
* <p><strong>Code Samples</strong></p> | ||
* | ||
* {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.getBlobName} | ||
* | ||
* @return The name of the blob. | ||
* @return The decoded name of the blob. | ||
*/ | ||
public final String getBlobName() { | ||
return blobName; | ||
return (blobName == null) ? null : Utility.urlDecode(blobName); | ||
} | ||
|
||
/** | ||
|
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.
This should just call into the next overload so we don't have to worry about missing formatting/encoding logic in one of them
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.
You are right, let's make it call the next overload.