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
MAX_TAGS =

A tag costs time and memory to build however few bytes it spends, so the count is bounded as well as the size. Room for some 500 records

25_000
EXPANSION_ABANDONED =

REXML raises a bare RuntimeError when expansion limits trip

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

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Document

Returns a new instance of Document.



20
21
22
# File 'lib/mailreport/dmarc/document.rb', line 20

def initialize(xml)
  @xml = xml
end

Instance Method Details

#reportObject



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mailreport/dmarc/document.rb', line 24

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