Skip to content
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

Control characters in message returned from server #67

Open
BraveThrasher opened this issue Feb 8, 2018 · 0 comments
Open

Control characters in message returned from server #67

BraveThrasher opened this issue Feb 8, 2018 · 0 comments

Comments

@BraveThrasher
Copy link

It can happen that messages returned by the server start with control characters (non-printable characters) but after those control characters comes a valid message (starting with a '+') from the server. Those control characters should not be taken into account when checking a message for validity.

We get this on a very regular basis and getting an exception each time is very annoying. We handle exceptions by logging them and the log file gets swamped by the exceptions that are being thrown because of this.

The utility method ReadLineAsBytes in StreamUtility.cs should also include a check for control characters in the following piece of code.

// Do not write \r or \n
if (readChar != '\r' && readChar != '\n')
	memoryStream.WriteByte((byte)justRead);

It only needs to be altered as follows.

// Do not write \r or \n
if (readChar != '\r' && readChar != '\n' && !char.IsControl(readChar))
	memoryStream.WriteByte((byte)justRead);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant