Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

bump html-pipeline

ulfertsff0ce75ea027
diff --git a/Gemfile.lock b/Gemfile.lock
index 378cca5c30f..26b3fa393da 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -487,7 +487,7 @@ GEM
hashdiff (1.0.0)
hashery (2.1.2)
hashie (3.6.0)
- html-pipeline (2.8.3)
+ html-pipeline (2.8.4)
activesupport (>= 2)
nokogiri (>= 1.4)
htmldiff (0.0.1)
diff --git a/lib/open_project/text_formatting/filters/sanitization_filter.rb b/lib/open_project/text_formatting/filters/sanitization_filter.rb
index d01fe8ce74c..bea52dfd0aa 100644
--- a/lib/open_project/text_formatting/filters/sanitization_filter.rb
+++ b/lib/open_project/text_formatting/filters/sanitization_filter.rb
@@ -31,9 +31,13 @@
module OpenProject::TextFormatting
module Filters
class SanitizationFilter < HTML::Pipeline::SanitizationFilter
- WHITELIST[:elements] << 'macro'
- # Whitelist class and data-* attributes on all macros
- WHITELIST[:attributes].merge!('macro' => ['class', :data])
+ def context
+ super.merge(whitelist: WHITELIST.merge(
+ elements: WHITELIST[:elements] + ['macro'],
+ # Whitelist class and data-* attributes on all macros
+ attributes: WHITELIST[:attributes].merge('macro' => ['class', :data])
+ ))
+ end
end
end
end
diff --git a/lib/open_project/text_formatting/formats/base_formatter.rb b/lib/open_project/text_formatting/formats/base_formatter.rb
index 1b1ad9dccbd..80fe64261af 100644
--- a/lib/open_project/text_formatting/formats/base_formatter.rb
+++ b/lib/open_project/text_formatting/formats/base_formatter.rb
@@ -29,11 +29,12 @@
module OpenProject::TextFormatting::Formats
class BaseFormatter
- attr_reader :options, :project
+ attr_reader :context,
+ :pipeline
- def initialize(options)
- @options = options
- @project = options[:project]
+ def initialize(context)
+ @context = context
+ @pipeline = HTML::Pipeline.new(located_filters, context)
end
def to_html(text)
diff --git a/lib/open_project/text_formatting/formats/markdown/formatter.rb b/lib/open_project/text_formatting/formats/markdown/formatter.rb
index 1fcda6ca624..a782f78d850 100644
--- a/lib/open_project/text_formatting/formats/markdown/formatter.rb
+++ b/lib/open_project/text_formatting/formats/markdown/formatter.rb
@@ -31,14 +31,6 @@ require 'task_list/filter'
module OpenProject::TextFormatting::Formats::Markdown
class Formatter < OpenProject::TextFormatting::Formats::BaseFormatter
- attr_reader :context,
- :pipeline
-
- def initialize(context)
- @context = context
- @pipeline = ::HTML::Pipeline.new(located_filters, context)
- end
-
def to_html(text)
result = pipeline.call(text, context)
output = result[:output].to_s
diff --git a/lib/open_project/text_formatting/formats/plain/formatter.rb b/lib/open_project/text_formatting/formats/plain/formatter.rb
index cbab6486f4d..99191c240ed 100644
--- a/lib/open_project/text_formatting/formats/plain/formatter.rb
+++ b/lib/open_project/text_formatting/formats/plain/formatter.rb
@@ -31,14 +31,6 @@
module OpenProject::TextFormatting::Formats
module Plain
class Formatter < OpenProject::TextFormatting::Formats::BaseFormatter
- attr_reader :context,
- :pipeline
-
- def initialize(context)
- @context = context
- @pipeline = HTML::Pipeline.new(located_filters, context)
- end
-
def to_html(text)
pipeline.to_html(text, context).html_safe
end