module Mail::Utilities

Extended Modules

Defined in:

mail/utilities.cr

Constant Summary

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

Class Method Summary

Instance Method Summary

Class Method Detail

def self.binary_unsafe_to_crlf(string) #

[View source]
def self.binary_unsafe_to_lf(string) #

[View source]
def self.safe_for_line_ending_conversion?(string) #

[View source]
def self.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.


[View source]

Instance Method Detail

def atom_safe?(str) #

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


[View source]
def 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?


[View source]
def 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'


[View source]
def 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"'


[View source]
def escape_paren(str) #

Escape parenthesies in a string

Example:

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


[View source]
def 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


[View source]
def 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...


[View source]
def 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


[View source]
def token_safe?(str) #

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


[View source]
def 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'


[View source]
def 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""'


[View source]
def 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"'


[View source]