Class: Net::IMAP::RawText
Do not use. This class is for internal use only.
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
CommandData,
Data
|
|
|
Instance Chain:
self,
CommandData,
Data
|
|
| Inherits: |
Net::IMAP::CommandData
|
| Defined in: | lib/net/imap/command_data.rb |
Overview
Represents IMAP text data, which may contain any 7-bit ASCII character,
except for NULL, CR, or LF. text is extended to allow any
multibyte UTF-8 character when either UTF8=ACCEPT or IMAP4rev2 have
been enabled, or when the server supports only IMAP4rev2 and not earlier
::Net::IMAP revisions, or when the server advertises UTF8=ONLY.
NOTE: The current implementation does not validate whether the connection currently supports UTF-8. Future versions may change.
The string's bytes must be valid ASCII or valid UTF-8. The string's reported encoding is ignored, but the string is not transcoded.
Class Method Summary
Instance Attribute Summary
Instance Method Summary
Constructor Details
.new(data:) ⇒ RawText
# File 'lib/net/imap/command_data.rb', line 169
def initialize(data:) data = String(data.to_str) data = if data.encoding in Encoding::ASCII | Encoding::UTF_8 -data elsif data.ascii_only? -(data.dup.force_encoding("ASCII")) else -(data.dup.force_encoding("UTF-8")) end super validate end
Instance Attribute Details
#ascii_only? ⇒ Boolean (readonly)
[ GitHub ]
# File 'lib/net/imap/command_data.rb', line 192
def ascii_only? = data.ascii_only?
Instance Method Details
#send_data(imap, tag)
[ GitHub ]# File 'lib/net/imap/command_data.rb', line 194
def send_data(imap, tag) = imap.__send__(:put_string, data)
#validate
[ GitHub ]# File 'lib/net/imap/command_data.rb', line 182
def validate if data.include?("\0") raise DataFormatError, "NULL byte must be binary literal encoded" elsif !data.valid_encoding? raise DataFormatError, "invalid UTF-8 must be literal encoded" elsif /[\r\n]/.match?(data) raise DataFormatError, "CR and LF bytes must be literal encoded" end end