question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] BlobClient Name is getting URL Encoded

See original GitHub issue

Describe the bug If the blob.Name contains “/” like in a hierarchical structure, in the BlobClient, the name is escaped to %2F for the slashes. This passes through in the blobClient.Uri, which returns https://<accountname>.blob.core.windows.net/<containername>/blobroot%2Fsubfolder%2Fblobname.ext as an example.

This works in some browsers still, but if the URL is URL Encoded, which it should be able to, it then breaks because the % symbols causes issues with future URL encoding where they get converted into %25, plus the 2F, turns in to %252F.

Expected behavior If the blob.Name has “/” then it should stay as “/” and not be escaped to %2F

Actual behavior (include Exception or Stack Trace) Blob name passed in as “blobroot/subfolder/blobname.ext” is converted to “blobroot%2Fsubfolder%2Fblobname.ext”

To Reproduce Steps to reproduce the behavior (include a code snippet, screenshot, or any additional information that might help us reproduce the issue)

  1. Create a BlobClient with a hierarchical name containing at least one subfolder.
  2. Then look at the blobClient.Uri and you will see that the blob Name has been escaped.

Environment:

  • Azure.Storage.Blobs 12.6.0
  • .NET Core 2.2
  • Visual Studio 2019

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
SiobhanBaynescommented, Aug 10, 2021

I can get the name by using blobClient.Name but then I have to do some string manipulation to get the full URI. If the service considers them the same, then I don’t see why it can’t return unescaped and let me decide whether it should be escaped or not. If nothing else then it should be consistent in the way in which it returns them.

0reactions
seanmcc-msftcommented, Feb 4, 2021

The service considers “/“ and “%20” to be the same character. In addition, you can get the unescaped blob name with BlobClient.Name.

Read more comments on GitHub >

github_iconTop Results From Across the Web

BlobClient class
This method accepts an encoded URL or non-encoded URL pointing to a blob. Encoded URL string will NOT be escaped twice, only special...
Read more >
URI for CloudBlockBlob is giving special characters in c# - ...
Because your container name contains a URL reserved character ( \ ), it is getting URL encoded as %5C .
Read more >
BlobClientBuilder (Azure SDK for Java Reference ... - NET
Creates a BlobClient based on options set in the builder. ... If the blob name contains special characters, pass in the url encoded...
Read more >
BlobContainerClient (Azure SDK for Java Reference ...
If the blob name contains special characters, pass in the url encoded version of the blob name. Code Samples BlobClient blobClient = client....
Read more >
Blob is not defined. We reviewed this issue and determined that
Gets the data of this blob as a string with the specified encoding. When the body is an Array we will set proper...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found