bentonstark / starksoft-aspen

.net / mono security and cryptography library that provides client support for ftps, gnupg, smartcard, and socks / http proxies
108 stars 49 forks source link

Fix problem with replacing any non-ascii chars to char with code 65533. #47

Closed Piatkosia closed 4 years ago

Piatkosia commented 4 years ago

Hi. I fixed problem with exception. For example my windows console is used 852 codepage and for non-ascii chars exception looks like this: e.Message.ToCharArray() {char[119]}

[1]: 112 'p'
[2]: 103 'g'
[3]: 58 ':'
[4]: 32 ' '
[5]: 69 'E'
[6]: 65 'A'
[7]: 52 '4'
[8]: 55 '7'
[9]: 56 '8'
[10]: 69 'E'
[11]: 65 'A'
[12]: 55 '7'
[13]: 58 ':'
[14]: 32 ' '
[15]: 112 'p'
[16]: 111 'o'
[17]: 109 'm'
[18]: 105 'i'
[19]: 110 'n'
[20]: 105 'i'
[21]: 65533 '�'
[22]: 116 't'
[23]: 121 'y'

To fix it one parameter to stream reader for exception must be added. It always try to read stream with the same encoding like standard error stream, not .net default one. Now string is correct or convertable (because not all non-ascii chars are replaced by 65533 '�' ).

This is only one line fix.

Piatkosia commented 4 years ago

Thanks for merge;) Please let me know when nuget package with this change will be ready;)

bentonstark commented 4 years ago

Ok. I should be able to get that done this evening. Thanks for the submissions!

On Mar 3, 2020, at 12:48 AM, Angelika Maria Piątkowska notifications@github.com wrote:

 Thanks for merge;) Please let me know when nuget package with this change will be ready;)

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.

Piatkosia commented 4 years ago

It looks fine for console app but I still have a problem in general under WPF. Work in progress.