Skip to content

Commit

Permalink
fix(dkim): fixes bug with signing dkim bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcooke committed Jul 28, 2021
1 parent 21a8d89 commit 189dfa5
Show file tree
Hide file tree
Showing 4 changed files with 1,022 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/postal/dkim_header.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def initialize(domain, message)
end
@domain = domain
@message = message
@raw_headers, @raw_body = @message.split(/\r?\n\r?\n/, 2)
@raw_headers, @raw_body = @message.gsub(/\r?\n/, "\r\n").split(/\r\n\r\n/, 2)
end

def dkim_header
Expand Down Expand Up @@ -76,17 +76,18 @@ def normalized_body

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

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

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

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

content += "\r\n"
content
end
end

Expand Down
File renamed without changes.
Loading

0 comments on commit 189dfa5

Please sign in to comment.