-
Notifications
You must be signed in to change notification settings - Fork 25
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
Checking that parsed OTR protocol version is a digit is broken with python3 #56
Comments
It has also been suggested on irc that it might be wise to drop the conversion altogeher and just deal with bytes as-is when checking for different protocol versions? |
What? No, it doesn't do that. And
EDIT: python2 has the same behavior when using unicode strings:
|
You are correct, I mixed up my copy/pastes :) My point was that isdigit() does not do what this line was used for in our code back when we used python2. |
I agree, this comparison should deal in bytes and not care about isdigit(). On January 16, 2015 12:50:29 AM CET, koolfy [email protected] wrote:
|
Wow this is old now. |
This line is problematic: https://github.com/python-otr/pure-python-otr/blob/staging/src/potr/proto.py#L134
Its purpose is to check that the parsed OTR tag advertises a correct protocol version by checking that the value is a digit.
First, since python3, isdigit() (and posssibly isdecimal and isnumeric) goes by a quite wider definition of "digit". For example, UTF-8 characters other than 0-9, but representing symbols containing a digit in them will match, as well as digits from other alphabets.
Example:
First, this caused panic and anger, but then, reading the OTRv2 spec:
we actually realised any byte might at some point designate a version. It just happens that the ascii value "2" was chosen.
In that context, a better option might be to remove this isdigit() test altogether, as it does not reflect a specification constraint.
The text was updated successfully, but these errors were encountered: