-
Notifications
You must be signed in to change notification settings - Fork 180
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
Raising MemcacheIllegalInputError when key contains null byte, newline, or carriage return #138
Conversation
…line, or carriage return
Changing byte -> character
With this change, we are walking the entire key string three times to do validation. It's probably worth doing one walk, and checking each character along the way, rather than using "in" to do the work. |
@cgordon I agree. I updated the commit to iterate over the characters once. I also split out the check for newline to enable a more specific error message. |
The tests were failing because the character checks differ between python 2 and 3. Iterating over the binary string in python 2 returns characters, while python 3 returns the ordinal value. I am not that familiar with a better way to handle this. If you have any suggestions, please let me know! Edit: I converted the key to a byte array instead |
This looks good to me, thanks for the catch, and the improved optimized traversing. The build is failing for an unrelated issue, which will be fixed in #140 Once that's merged, please rebase and push, and we can go ahead and merge this. |
Merging latest commits
@nichochar thanks for the update! Pulled in the latest changes. |
Memcache does not support setting keys with null byte, newline, carriage return. This adds support for checking the key to ensure the key is valid.
Setting keys with these returns the following exception:
This has been tested using version 1.3.5 on python 2.7.10