module Mail::Utilities
Extended Modules
Defined in:
mail/utilities.crConstant Summary
-
TO_CRLF_REGEX =
Regex.new("(?<!\r)\n|\r(?!\n)")
Class Method Summary
- .binary_unsafe_to_crlf(string)
- .binary_unsafe_to_lf(string)
- .safe_for_line_ending_conversion?(string)
-
.to_crlf(string)
Convert line endings to \r\n unless the string is binary.
Instance Method Summary
-
#atom_safe?(str)
Returns true if the string supplied is free from characters not allowed as an ATOM
-
#blank?(value)
Returns true if the object is considered blank.
-
#dasherize(str)
Swaps out all underscores (_) for hyphens (-) good for stringing from symbols a field name.
-
#dquote(str)
Wraps supplied string in double quotes and applies -escaping as necessary, unless it is already wrapped.
-
#escape_paren(str)
Escape parenthesies in a string
-
#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
-
#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...
-
#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
-
#token_safe?(str)
Returns true if the string supplied is free from characters not allowed as a TOKEN
-
#underscoreize(str)
Swaps out all hyphens (-) for underscores (_) good for stringing to symbols a field name.
-
#unescape(str)
Removes any -escaping.
-
#unquote(str)
Unwraps supplied string from inside double quotes and removes any -escaping.
Class Method Detail
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.
Instance Method Detail
Returns true if the string supplied is free from characters not allowed as an ATOM
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?
Swaps out all underscores (_) for hyphens (-) good for stringing from symbols a field name.
Example:
string = :resent_from_field dasherize( string ) #=> 'resent-from-field'
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"'
Escape parenthesies in a string
Example:
str = 'This is (a) string' escape_paren( str ) #=> 'This is (a) string'
If the string supplied has ATOM unsafe characters in it, will return the string quoted in double quotes, otherwise returns the string unmodified
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...
If the string supplied has TOKEN unsafe characters in it, will return the string quoted in double quotes, otherwise returns the string unmodified
Returns true if the string supplied is free from characters not allowed as a TOKEN
Swaps out all hyphens (-) for underscores (_) good for stringing to symbols a field name.
Example:
string = :resent_from_field underscoreize ( string ) #=> 'resent_from_field'
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""'
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"'