Class: Gitlab::FogbugzImport::XmlAdapter
- Inherits:
-
Object
- Object
- Gitlab::FogbugzImport::XmlAdapter
- Defined in:
- lib/gitlab/fogbugz_import/xml_adapter.rb
Constant Summary collapse
- ResponseTooLargeError =
Class.new(StandardError)
- MAX_ALLOWED_BYTES =
5.megabytes
- MAX_ALLOWED_OBJECTS =
250_000
Class Method Summary collapse
Class Method Details
.parse(xml) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/gitlab/fogbugz_import/xml_adapter.rb', line 46 def self.parse(xml) if xml.bytesize > MAX_ALLOWED_BYTES raise ResponseTooLargeError, "XML exceeds permitted size: #{xml.bytesize}/#{MAX_ALLOWED_BYTES} bytes" end # We use ActiveSupport::XmlMini to get a simplified hash structure, # aligned with what we were previously expecting from Crack, but we use # Nokogiri for performance and security reasons. ActiveSupport::XmlMini.with_backend(NokogiriBackendWithLimits) do Hash.from_xml(xml)['response'] rescue Nokogiri::XML::SyntaxError nil end end |