Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/paubox/format_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ module FormatHelper
def base64_encoded?(value)
return false unless value.is_a?(String)

!value.strip.match(BASE64_REGEX).nil?
Base64.strict_encode64(Base64.decode64(value)) == value
end

def base64_encode_if_needed(str)
return str if base64_encoded?(str.to_s)

Base64.encode64(str.to_s)
Base64.strict_encode64(str.to_s)
end

# Converts hash keys to strings and maps them to expected JSON key.
Expand Down
3 changes: 2 additions & 1 deletion lib/paubox/mail_to_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def send_message_payload
private

def build_attachments
puts 'MailToMessage build_attachments'
attachments = mail.attachments
return [] if attachments.empty?

Expand Down Expand Up @@ -88,7 +89,7 @@ def convert_binary_to_base64(f)
file = Tempfile.new(encoding: 'ascii-8bit')
file.write(f)
file.rewind
Base64.encode64(file.read)
Base64.strict_encode64(file.read.delete("\n"))
end
end
end
4 changes: 2 additions & 2 deletions lib/paubox/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def send_message_payload
def add_attachment(file_path)
@packaged_attachments << { filename: file_path.split('/').last,
content_type: `file --b --mime-type #{file_path}`.chomp,
content: Base64.encode64(File.read(file_path)) }
content: Base64.strict_encode64(File.read(file_path)) }
end

def attachments
Expand All @@ -46,7 +46,7 @@ def build_attachments(args)
return (@packaged_attachments = []) if args.to_a.empty?

args.each do |a|
a[:content] = base64_encode_if_needed(a[:content])
a[:content] = base64_encode_if_needed(("#{a[:content]}").delete("\n"))
@packaged_attachments << a
end
@packaged_attachments
Expand Down
2 changes: 1 addition & 1 deletion lib/paubox/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Paubox
VERSION = '0.3.2'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really bizarre, and why is this seemingly crucial hotfix dead for 10 months now? Is Paubox dead?

VERSION = '0.4.6'
end
2 changes: 1 addition & 1 deletion spec/helpers/mail_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def message_with_attachments(args = {})
def base64_encode_if_needed(str)
return str if base64_encoded?(str.to_s)

Base64.encode64(str.to_s)
Base64.strict_encode64(str.to_s)
end
end
end
4 changes: 2 additions & 2 deletions spec/helpers/message_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ def message_with_template_args(args = {})
def base64_encoded?(value)
return false unless value.is_a?(String)

!value.strip.match(BASE64_REGEX).nil?
Base64.strict_encode64(Base64.decode64(value)) == value
end

def base64_encode_if_needed(str)
return str if base64_encoded?(str.to_s)

Base64.encode64(str.to_s)
Base64.strict_encode64(str.to_s)
end
end
end