dotnet/aspnetcore

Stop using InvalidOperationExceptions to signal invalid ASCII during parsing

Open

#4736 aperta il 19 lug 2018

Vedi su GitHub
 (4 commenti) (0 reazioni) (0 assegnatari)C# (10.653 fork)batch import
affected-very-fewarea-networkingenhancementfeature-kestrelhelp wantedseverity-nice-to-have

Metriche repository

Star
 (37.933 star)
Metriche merge PR
 (Merge medio 16g 9h) (258 PR mergiate in 30 g)

Descrizione

GetAsciiStringNonNullCharacters() currently throws an InvalidOperationException fo invalid or chacters, and the parsing logic catches these InvalidOperationExceptions at various layers to handle the bad request appropriately.

Ideally we could switch to calling a TryGetAsciiStringNonNullCharacters method, but if propagating failure down the stack proves too difficult, we should at least move to a custom exception type so we don't end up obscuring real product bugs by inadvertently swallowing InvalidOperationExceptions thrown by other methods.

Guida contributor