Class: Dkim::Body

Inherits:
Struct
  • Object
show all
Includes:
Canonicalizable
Defined in:
lib/dkim/body.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Canonicalizable

#to_s

Instance Attribute Details

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



4
5
6
# File 'lib/dkim/body.rb', line 4

def body
  @body
end

Instance Method Details

#canonical_relaxedObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/dkim/body.rb', line 7

def canonical_relaxed
  # special case from errata 1377
  return "" if self.body.empty?

  body = self.body.dup

  # Reduces all sequences of WSP within a line to a single SP character.
  body.gsub!(/[ \t]+/, ' ')

  # Ignores all whitespace at the end of lines.  Implementations MUST NOT remove the CRLF at the end of the line.
  body.gsub!(/ \r\n/, "\r\n")

  # Ignores all empty lines at the end of the message body.
  body.gsub!(/[ \r\n]*\z/, '')

  body += "\r\n"
end

#canonical_simpleObject



24
25
26
27
28
29
30
# File 'lib/dkim/body.rb', line 24

def canonical_simple
  body = self.body.dup

  # Ignores all empty lines at the end of the message body.
  body.gsub!(/(\r?\n)*\z/, '')
  body += "\r\n"
end