Skip to content

Support parsing XML with huge nodes

Zhiyuan Lu requested to merge gitlab-jh/jh-team/gitlab:fix-huge-xml-parse into master

What does this MR do and why?

The Hash.from_xml we used does not support parsing XML containing huge nodes. Currently MR changes it to Nokogiri::XML with HUGE parameter to solve this problem.

Surprisingly, this not only solves the current bug, but will even improve the speed of parsing xml 🚀. ( See !148779 (comment 1853485283) )

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

No UI changes.

How to set up and validate locally

The Spec spec/lib/gitlab/xml_converter_spec.rb has clearly tested this process.

huge_xml = URI.open('https://jihulab.com/test-xml-error/project1/-/raw/main/test.xml?ref_type=heads').read
Hash.from_xml(huge_xml) # Error!

doc = Nokogiri::XML(xml, &:huge)
doc.to_hash # Success!
doc.errors # is `[]`!
Edited by Zhiyuan Lu

Merge request reports

Loading