Class: MailReport::Dmarc::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/mailreport/dmarc/document.rb

Overview

RFC 7489 Appendix C.

Constant Summary collapse

ROOT =
"feedback"
PREDEFINED_ENTITIES =
%w[ lt gt amp quot apos ].freeze
EXPANSION_ABANDONED =

REXML raises a bare RuntimeError when expansion limits trip; match the message so our own RuntimeErrors are not swallowed as unreadable input.

/entity expansions exceeded|entity expansion has grown too large/

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Document

Returns a new instance of Document.



17
18
19
# File 'lib/mailreport/dmarc/document.rb', line 17

def initialize(xml)
  @xml = xml
end

Instance Method Details

#reportObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/mailreport/dmarc/document.rb', line 21

def report
  if root = feedback
    build(root)
  end
rescue REXML::ParseException
  nil
rescue RuntimeError => error
  if error.message.match?(EXPANSION_ABANDONED)
    nil
  else
    raise
  end
end