.Net: Bug: BinaryContent does not decode the %xx escapes of a non-base64 data URI
Maintainers usually reply within 4 days
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Start at BinaryContent.GetCachedByteArrayContent and review the existing DataUriParser tests, which document that non-base64 data remains escaped there. Verify the conversion to bytes for the two reported inputs: the text becomes “A brief note” and the binary data becomes FF 00 80, with coverage for both cases.
Written by the indexing model from the issue text.
Description
Describe the bug
BinaryContent, and so ImageContent and AudioContent, built from a data URI without ;base64 returns the URI's data as UTF-8 text with the %xx escapes still in it. DataUriParser follows RFC 2397, where "the data (as a sequence of octets) is represented using ASCII encoding for octets inside the range of safe URL characters and using the standard %xx hex encoding of URLs for octets outside that range".
To Reproduce
var content = new BinaryContent("data:,A%20brief%20note");
Console.WriteLine(Encoding.UTF8.GetString(content.Data!.Value.Span)); // A%20brief%20note
Data as hex:
data:,A%20brief%20note -> 41 25 32 30 62 72 69 65 66 25 32 30 6E 6F 74 65 ("A%20brief%20note")
data:application/octet-stream,%FF%00%80 -> 25 46 46 25 30 30 25 38 30 ("%FF%00%80")
Expected behavior
A brief note, as in the RFC 2397 example ("The URL data:,A%20brief%20note encodes the text/plain string "A brief note""), and the three octets FF 00 80.
Platform
- Language: C#
- Source: NuGet Microsoft.SemanticKernel.Abstractions 1.80.1, also main at 58ad1a378
- OS: Linux (mcr.microsoft.com/dotnet/sdk:10.0)
Additional context
BinaryContent.GetCachedByteArrayContent returns Encoding.UTF8.GetBytes(parsedDataUri.Data) for non-base64 data. DataUriParser keeps the data escaped (its tests expect A%20brief%20note), so the decoding belongs to the conversion to bytes.
- Dominant language
- C#
- Stars
- 28.6k
- Forks
- 4.8k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 12
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/semantic-kernel
-
.Net: gpt-image-1 is the default image model in the .NET OpenAI connector, and OpenAI shuts it down on October 23Possibly taken @nightcityblade claimed this 2 days ago. Open.NET triage
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
microsoft/semantic-kernel#14526 · 1 comment ·
Maintainers usually reply within 4 days
-
Python: VolatileMemoryStore.get_batch and get_nearest_matches ignore with_embeddings=False (deepcopy result is discarded)Possibly taken @VANDRANKI claimed this 4 days ago. Openpython triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
microsoft/semantic-kernel#14522 ·
Maintainers usually reply within 4 days
-
Python: VolatileMemoryStore.get_nearest_match returns an un-awaited coroutine instead of a (MemoryRecord, score) tuplePossibly taken @VANDRANKI claimed this 4 days ago. Openpython triage
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
microsoft/semantic-kernel#14521 ·
Maintainers usually reply within 4 days
-
Python: FunctionCallContent.combine_arguments drops a streamed "{}" chunk, producing invalid JSON argumentsPossibly taken @VANDRANKI claimed this 5 days ago. Openpython triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
microsoft/semantic-kernel#14512 · 2 comments ·
Maintainers usually reply within 4 days
-
.Net: Python: KernelJsonSchemaBuilder emits {"type": "object"} with no enum for typing.Literal parameters and fieldsPossibly taken @VANDRANKI claimed this 5 days ago. Open.NET python triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
microsoft/semantic-kernel#14511 ·
Maintainers usually reply within 4 days
All issues in microsoft/semantic-kernel
Similar issues
-
[Doc Gap] Document new --enable-public-network-access breaking change for azurebackup vault createOpencopilot documentation
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
area-dashboard
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
0 - Backlog Bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
BrighterCommand/Brighter#4539 ·
Maintainers usually reply within 1 day
-
area-networking
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
dotnet/aspnetcore#69671 · 1 comment ·
Maintainers usually reply within 1 day
-
test
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NethermindEth/nethermind#14274 ·
Maintainers usually reply within 1 day