From 620b7da4ad6bd32f7d689b8d8b442776e5970701 Mon Sep 17 00:00:00 2001 From: Janiss Binder Date: Mon, 16 Dec 2024 12:24:52 +0100 Subject: [PATCH] Make SAX Parser nokogiri 17 compatible Due to changes in nokogiri 17, the SAX parser now needs a default encoding: https://github.com/sparklemotion/nokogiri/pull/3288 --- lib/prawn/markup/processor.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/prawn/markup/processor.rb b/lib/prawn/markup/processor.rb index d2d9a03..195c743 100644 --- a/lib/prawn/markup/processor.rb +++ b/lib/prawn/markup/processor.rb @@ -49,7 +49,9 @@ def parse(html) reset html = Prawn::Markup::Normalizer.new(html).normalize - Nokogiri::HTML::SAX::Parser.new(self).parse(html) { |ctx| ctx.recovery = true } + Nokogiri::HTML::SAX::Parser.new(self, html.encoding&.to_s).parse(html) do |ctx| + ctx.recovery = true + end end def start_element(name, attrs = [])