Skip to content

Commit

Permalink
fix: set the DOCTYPE by removing the DTD and creating a new one
Browse files Browse the repository at this point in the history
because GNOME/libxml2@8d0aaf4 prevents us from changing the node name
in libxml >= 2.13.0.

See discussion in #3230 for context.
  • Loading branch information
flavorjones committed Jun 12, 2024
1 parent 48746be commit 26ae4db
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/sanitize/transformers/clean_doctype.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ class Sanitize; module Transformers

if node.type == Nokogiri::XML::Node::DTD_NODE
if env[:config][:allow_doctype]
node.name = 'html'
if node.name != "html"
document = node.document
node.unlink
document.create_internal_subset("html", nil, nil)
end
else
node.unlink
end
Expand Down

0 comments on commit 26ae4db

Please sign in to comment.