DataContent rejects RFC 2397 data URIs that give only a charset (data:;charset=utf-8,...)
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Đọc src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/DataUriParser.cs quanh lệnh gọi MediaTypeHeaderValue.TryParse, sau đó kiểm tra DataContent.cs và các bài kiểm thử của nó. Bổ sung kiểm thử cho ba trường hợp tái hiện, bao gồm siêu dữ liệu chỉ có tham số, có và không có ;base64, cùng một kiểu phương tiện được chỉ định tường minh. Hoàn tất khi tất cả các trường hợp được phân tích thành các byte hello và tạo ra kiểu phương tiện như mong đợi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
RFC 2397 allows the text/plain part of the media type to be omitted while the charset is still given:
As a shorthand, "text/plain" can be omitted but the charset parameter supplied.
So data:;charset=utf-8,hello is a valid data URI.
DataContent throws on it. #7247 fixed the case where the whole media type is omitted (data:;base64,...), but when the metadata holds only parameters (with or without ;base64), DataUriParser.Parse hands ;charset=utf-8 to MediaTypeHeaderValue.TryParse, which fails: https://github.com/dotnet/extensions/blob/8cf4ff6658e9b36eca01ac6045ea9835f3b3b751/src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/DataUriParser.cs#L68-L77
Passing mediaType explicitly does not help, because the URI is parsed before the supplied media type is looked at: https://github.com/dotnet/extensions/blob/8cf4ff6658e9b36eca01ac6045ea9835f3b3b751/src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/DataContent.cs#L93-L96
Reproduction Steps
using Microsoft.Extensions.AI;
var a = new DataContent("data:;charset=utf-8,hello");
var b = new DataContent("data:;charset=utf-8;base64,aGVsbG8=");
var c = new DataContent("data:;charset=utf-8,hello", "text/plain");
Expected behavior
All three parse to the bytes of hello. The first two get media type text/plain;charset=utf-8, the same as data:text/plain;charset=utf-8,hello; the third keeps the supplied text/plain.
Actual behavior
Each one throws:
System.UriFormatException: Invalid data URI format: the media type is not a valid.
Regression?
No, this shape never parsed as far as I can tell. #7247 covered only the empty media type.
Known Workarounds
Insert text/plain after data: before constructing the DataContent.
Configuration
main at 8cf4ff6658e9b36eca01ac6045ea9835f3b3b751, .NET 10.0.103 SDK, Windows 11 x64. Not configuration specific; the parsing is plain string handling.
Other information
Related: #7246 / #7247. Happy to send a PR with tests if this is wanted.
- Ngôn ngữ chính
- C#
- Star
- 3.3k
- Fork
- 925
- Merge trung bình
- 2 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 28
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dotnet/extensions
-
area-fundamentals bug untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
dotnet/extensions#7979 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area-ai untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
dotnet/extensions#7956 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[MEAI.OpenAI] OpenAIResponsesChatClient streams reasoning and non-message items with Role=null, merging them into preceding Tool messages ```Có thể đã có người làm @caigen đã nhận 4 ngày trước. Đang mởarea-ai bug untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
dotnet/extensions#7954 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ServiceEndpointWatcher logs normal cancellation as an errorCó thể làm lại được @seragAhmed đã nhận 13 ngày trước và không có pull request nào đang mở. Đang mởbug untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
dotnet/extensions#7940 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
OpenAISpeechToTextClient sends Ogg MemoryStream audio with an .mp3 filenameCó thể đã có người làm @Manish-1kumar đã nhận 24 ngày trước. Đang mởarea-ai untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
dotnet/extensions#7900 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của dotnet/extensions
Issue tương tự
-
Scaffold marks an association as required when its composite foreign key has a nullable columnĐang mởarea: scaffold status: needs-tests
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
provider:flagd type:fix
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
open-feature/dotnet-sdk-contrib#789 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 72/100
NimblePros/Metronome#23 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
jsboige/CoursIA#28504 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
CustomUnits: Battle Armor squads play tank movement sounds (move-audio default ignores FakeVehicle)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100