Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set the DOCTYPE by removing the DTD and creating a new one #238

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion sanitize.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |s|
s.add_dependency('nokogiri', '>= 1.12.0')

# Development dependencies.
s.add_development_dependency('minitest', '~> 5.14.4')
s.add_development_dependency('minitest', '~> 5.15') # needs to float to support ruby 2.5 and 3.4
s.add_development_dependency('rake', '~> 13.0.6')

s.require_paths = ['lib']
Expand Down