Bug 10697 - DecoderFallbackException is not thrown correctly
Summary: DecoderFallbackException is not thrown correctly
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: Untriaged
Assignee: marcos.henrich
URL:
Depends on:
Blocks:
 
Reported: 2013-02-26 13:56 UTC by Gerardo García Peña
Modified: 2014-09-02 11:42 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Simple test case (3.50 KB, application/zip)
2013-02-26 13:56 UTC, Gerardo García Peña
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Gerardo García Peña 2013-02-26 13:56:40 UTC
Created attachment 3484 [details]
Simple test case

The DecoderFallbackException is not always thrown by the Decoder.Convert method, for instance, assuming a bad input byte array for this piece of code:

Encoding enc = Encoding.GetEncoding("XXX", new EncoderExceptionFallback(), new DecoderExceptionFallback());
Decoder dec = enc.GetDecoder();
dec.Convert(bytes, 0, 1, chars, 0, 1, true, out bytesUsed, out charsUsed, out completed);

This code will throw exceptions with the 'us-ascii' encoding as expected (array = 0xff), but it will work without exceptions with an incorrect 'utf-8' array (0xc3).

I've attached a simple test case with the output obtained under the MS implementation and the output running in a 2.10 mono environment. The MS implementation throws an Exception on both cases, Mono implementation only on the us-ascii try.
Comment 1 marcos.henrich 2014-09-02 11:42:57 UTC
Hi Gerardo,

Thank you for the detailed bug report.

This issue is fixed in master and mono-3.8.0-branch.