module

Mail::Utilities

Constants

TO_CRLF_REGEX = Regex.new("(?<!\r)\n|\r(?!\n)")

Class methods

binary_unsafe_to_crlf(string)
Source
binary_unsafe_to_lf(string)
Source
safe_for_line_ending_conversion?(string)
Source
to_crlf(string)

Convert line endings to \r\n unless the string is binary. Used for encoding 8bit and base64 Content-Transfer-Encoding and for convenience when parsing emails with \n line endings instead of the required \r\n.

Source

Instance methods

atom_safe?(str)

Returns true if the string supplied is free from characters not allowed as an ATOM

Source
blank?(value)

Returns true if the object is considered blank. A blank includes things like '', ' ', nil, and arrays and hashes that have nothing in them.

This logic is mostly shared with ActiveSupport's blank?

Source
dasherize(str)

Swaps out all underscores (_) for hyphens (-) good for stringing from symbols a field name.

Example:

string = :resent_from_field dasherize( string ) #=> 'resent-from-field'

Source
dquote(str)

Wraps supplied string in double quotes and applies -escaping as necessary, unless it is already wrapped.

Example:

string = 'This is a string' dquote(string) #=> '"This is a string"'

string = 'This is "a string"' dquote(string #=> '"This is "a string"'

Source
escape_paren(str)

Escape parenthesies in a string

Example:

str = 'This is (a) string' escape_paren( str ) #=> 'This is (a) string'

Source
quote_atom(str)

If the string supplied has ATOM unsafe characters in it, will return the string quoted in double quotes, otherwise returns the string unmodified

Source
quote_phrase(str)

If the string supplied has PHRASE unsafe characters in it, will return the string quoted in double quotes, otherwise returns the string unmodified TODO: Fix the quotation of unsafe phrases...

Source
quote_token(str)

If the string supplied has TOKEN unsafe characters in it, will return the string quoted in double quotes, otherwise returns the string unmodified

Source
token_safe?(str)

Returns true if the string supplied is free from characters not allowed as a TOKEN

Source
underscoreize(str)

Swaps out all hyphens (-) for underscores (_) good for stringing to symbols a field name.

Example:

string = :resent_from_field underscoreize ( string ) #=> 'resent_from_field'

Source
unescape(str)

Removes any -escaping.

Example:

string = 'This is "a string"' unescape(string) #=> 'This is "a string"'

string = '"This is "a string""' unescape(string) #=> '"This is "a string""'

Source
unquote(str)

Unwraps supplied string from inside double quotes and removes any -escaping.

Example:

string = '"This is a string"' unquote(string) #=> 'This is a string'

string = '"This is "a string""' unqoute(string) #=> 'This is "a string"'

Source