-
-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NETStandard, wrong codepage used in TNEF extractor #370
Comments
correct me if I'm wrong, but that sounds like a bug in netcore2's Encoding.GetEncoding() implementation, right? Could you submit a bug report to them to fix this? Thanks. |
It sounds like If it can't find an appropriate encoding to return, it is supposed to throw an exception. Can you verify this diagnosis? |
Yes, it looks exactly as netcore bug, I tried to submit report there, I wrote a very simple sample, just three lines of code:
And I feed exactly the same bytes to this fragment, it works. So I ended up here. GetEncoding doesn't return null, checked. Exception come from GetString, for sure. Thanks. |
Works around an NRE bug in netcore2 - issue #370
We probably don't need the exception fallbacks, so since that worked for you, I've committed a work-around. Hopefully the real bug gets fixed in netcore2 tho. |
Cool, thanks. |
Hi,
I've been trying to run TNEF extractor in dotnetcore2 environment when faced strange problem. HTML body of any message with codepage different from 1252 came out broken.
Debugger shows that
GetMessageEncoding().GetString(bytes, 0, length)
in TnefPropertyReader throws NullReferenceException, that causes fallback toDefaultEncoding.GetString(bytes, 0, length)
, e.g. to use default encoding, which is 1252.If I replace
Encoding.GetEncoding (codepage, new EncoderExceptionFallback(), new DecoderExceptionFallback())
in GetMessageEncoding() withEncoding.GetEncoding (codepage)
- things get back to normal.How to repeat:
TestExtractedCharset()
to the new projectAssert.AreEqual(expected, html)
I didn't find proper way to fix this. GetString never supposed to throw NullReference of course. On the other hand, I tried to pull exact test data and repeat misbehavior of GetString in clean project - no luck, it works fine, no exceptions, decoded correctly.
dotnet --version
2.1.4
Windows 10
The text was updated successfully, but these errors were encountered: