Skip to content

Commit c9ce352

Browse files
committed
Support REXML 3.3.3 invalid XML handling
With ruby/rexml@2bca7bd REXML now detects invalid XML with unsupported content before root element and raises REXML::ParseException rather than returning empty root. Support this REXML exception in Prawn::SVG::Document initializer.
1 parent ba87994 commit c9ce352

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/prawn/svg/document.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ class Prawn::SVG::Document
1717
:color_mode
1818

1919
def initialize(data, bounds, options, font_registry: nil, css_parser: CssParser::Parser.new, attribute_overrides: {})
20-
@root = REXML::Document.new(data).root
20+
begin
21+
@root = REXML::Document.new(data).root
22+
rescue REXML::ParseException
23+
@root = nil
24+
end
2125

2226
if @root.nil?
2327
if data.respond_to?(:end_with?) && data.end_with?('.svg')

0 commit comments

Comments
 (0)