DataContent rejects RFC 2397 data URIs that give only a charset (data:;charset=utf-8,...)
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
Línea de trabajo
Lee src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/DataUriParser.cs alrededor de la llamada a MediaTypeHeaderValue.TryParse y, después, inspecciona DataContent.cs y sus pruebas. Añade cobertura para los tres casos de reproducción, incluidos los metadatos que solo contienen parámetros, con y sin ;base64, y un tipo de medio explícito. El trabajo está terminado cuando todos los casos se analizan como los bytes hello y producen los tipos de medio esperados.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C#
- Estrellas
- 3.3k
- Forks
- 925
- Merge medio
- 2 d 7 h
- PR fusionados (30 d)
- 28
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de dotnet/extensions
-
area-fundamentals bug untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
dotnet/extensions#7979 ·
Los mantenedores suelen responder en 1 día
-
area-ai untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
dotnet/extensions#7956 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[MEAI.OpenAI] OpenAIResponsesChatClient streams reasoning and non-message items with Role=null, merging them into preceding Tool messages ```Posiblemente ocupada @caigen la tomó hace 4 días. Abiertoarea-ai bug untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
dotnet/extensions#7954 ·
Los mantenedores suelen responder en 1 día
-
ServiceEndpointWatcher logs normal cancellation as an errorQuizá libre de nuevo @seragAhmed la tomó hace 12 días y no hay ningún pull request abierto. Abiertobug untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
dotnet/extensions#7940 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
OpenAISpeechToTextClient sends Ogg MemoryStream audio with an .mp3 filenamePosiblemente ocupada @Manish-1kumar la tomó hace 23 días. Abiertoarea-ai untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
dotnet/extensions#7900 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de dotnet/extensions
Issues similares
-
要トリアージ
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
unoplatform/uno#26709 ·
Los mantenedores suelen responder en 1 día
-
area-Tools-ILLink untriaged
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
dotnet/runtime#138255 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
QuantConnect/Lean#10236 ·
Los mantenedores suelen responder en 1 día