diff --git a/lib/net/imap/command_data.rb b/lib/net/imap/command_data.rb index a0e04edb..1fd0dc30 100644 --- a/lib/net/imap/command_data.rb +++ b/lib/net/imap/command_data.rb @@ -58,7 +58,7 @@ def send_data(data, tag = nil) end end - UNQUOTABLE_CHARS = /\0\r\n/ + UNQUOTABLE_CHARS = /[\0\r\n]/ ASTRING_SPECIALS = /[(){ \x00-\x1f\x7f%*"\\]/ private_constant :UNQUOTABLE_CHARS, :ASTRING_SPECIALS diff --git a/test/net/imap/test_imap.rb b/test/net/imap/test_imap.rb index d005bc50..b178681c 100644 --- a/test/net/imap/test_imap.rb +++ b/test/net/imap/test_imap.rb @@ -1045,6 +1045,10 @@ def imap.test_args(*args) = send_command("TEST", *args) send_args.call ["\xDE\xAD\xBE\xEF".b] assert_equal "({4}\r\n\xDE\xAD\xBE\xEF)".b, server.commands.pop.args + send_args.call ["hi\rthere\n", "huh?\r\nfake out"] + assert_equal "({9}\r\nhi\rthere\n {14}\r\nhuh?\r\nfake out)".b, + server.commands.pop.args + # enable automatic non-synchronizing literals imap.config.max_non_synchronizing_literal = 1024 buff = bytes = nil