🐛 Fix bug (introduced by #712) testing if string is quotable#723
Merged
Conversation
This bug was introduced by a742a10. When I extracted the `UNQUOTABLE_CHARS` regexp into a constant, I didn't copied it exactly. It was converted from a character class into a sequence of bytes: ```ruby # It should've been this: UNQUOTABLE_CHARS = /[\0\r\n]/n # But I incorrectly copied it as this: UNQUOTABLE_CHARS = /\0\r\n/n ``` If that regexp were the only guard, this regexp would've allowed CRLF injections! Fortunately, quoted strings are now sent using `Net::IMAP::QuotedString` (since #698, released in v0.6.4.1), and that _does_ correctly validate that the input is a valid quoted string. So, the string isn't _sent_ as invalid quoted data. Unfortunately, this does result in an exception for strings that could be valid literals. And, because it crashes while sending command arguments, rather than during validation, the connection will be broken.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This bug was introduced by a742a10, as part of #712. When I extracted the
UNQUOTABLE_CHARSregexp into a constant, I didn't copied it exactly. It was converted from a character class into a sequence of bytes:If that regexp were the only guard, this regexp would've allowed CRLF injections! Fortunately, quoted strings are now sent using
Net::IMAP::QuotedString(since #698, released in v0.6.4.1), and that does correctly validate that the input is a valid quoted string. So, the string isn't sent as invalid quoted data.Unfortunately, this does result in an exception for strings that could be valid literals. And, because it crashes while sending command arguments, rather than during validation, the connection will be broken.