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
Nickname profile strips more whitespace characters than it should. #29
Comments
I will continue to strip "\t", "\n", and "\r" when they appear at the beginning and end of a nickname. The other control characters will no longer be stripped and the enforce() operation will fail with "DISALLOWED/controls". The Zl, Zp chars no longer be stripped, and the enforce() operation will fail with "DISALLOWED/other". |
IIRC all three of those characters ( |
You are correct that the characters My concern was that it might be surprising if I stopped stripping them now in the Nickname profile. After sleeping on it, I realize it's better to emit the "DISALLOWED/controls" diagnostic as I had deviated from the spec which only mentions Zs class white space characters. A Nickname is just a display name; it's not a user/login name. Basically, a nickname of "name\n" will now be DISALLOWED due to control characters. The previous version of the library automatically stripped the trailing "\n" and enforced the nickname to "name". (And it did this for all the leading/trailing Cc class chars that Python3 considers white space). |
Don't strip \t, \r, \n either. (See #29)
The Nickname profile includes an "additional mapping rule" that strips white space characters from both the beginning and end of the string. The current implementation uses the str.strip() method without a parameter. Python's default behavior defines a number of control characters as white space. I believe this is a bug; the code should be str.strip(' ') to just strip the standard ascii space.
The result of the Nickname
enforce
step is not affected by this bug. The code is simply over-permissive; it corrects the input more than it should. A diagnostic should tell the person to clean up their nickname string. A proper fix will include a diagnostic error message that reports "invalid_white_space". This will be a new error message.Current behavior that is not technically correct:
Note that non-ascii
Zs
white space are converted to ASCII space 0x20 before any stripping takes place. The Precis spec only talks about stripping theZs
white space chars.The following characters are stripped by Python:
Of these, I'm only worried about
\n
(U+0A). I might just continue to strip these, even though the spec doesn't say I have to. This is mostly for compatibility with existing software use.The text was updated successfully, but these errors were encountered: