mirror of
https://github.com/redmine/redmine.git
synced 2025-11-05 04:45:57 +01:00
Introduces a standalone html sanitizer class (#37750).
Patch by Jens Krämer. git-svn-id: https://svn.redmine.org/redmine/trunk@21900 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
20
lib/redmine/wiki_formatting/html_sanitizer.rb
Normal file
20
lib/redmine/wiki_formatting/html_sanitizer.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
module Redmine
|
||||
module WikiFormatting
|
||||
|
||||
# Combination of SanitizationFilter and ExternalLinksFilter
|
||||
class HtmlSanitizer
|
||||
|
||||
Pipeline = HTML::Pipeline.new([
|
||||
Redmine::WikiFormatting::CommonMark::SanitizationFilter,
|
||||
Redmine::WikiFormatting::CommonMark::ExternalLinksFilter,
|
||||
], {})
|
||||
|
||||
def self.call(html)
|
||||
result = Pipeline.call html
|
||||
result[:output].to_s
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user