diff options
author | Robert Speicher <robert@gitlab.com> | 2017-05-02 22:00:45 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-05-04 18:04:24 +0300 |
commit | 8da103e41378056535b7bd3df5634cb7f09044ee (patch) | |
tree | e761d5197516a9c980bb679c69f5d059d87d694c /lib | |
parent | 45d295052b95828c307e2d662e400885bac05da6 (diff) |
Merge branch 'bvl-markup-pipeline' into 'security'
Render asciidoc & other markup using banzai in a pipeline
See merge request !2088
Diffstat (limited to 'lib')
-rw-r--r-- | lib/banzai/pipeline/markup_pipeline.rb | 13 | ||||
-rw-r--r-- | lib/gitlab/asciidoc.rb | 7 | ||||
-rw-r--r-- | lib/gitlab/other_markup.rb | 5 |
3 files changed, 18 insertions, 7 deletions
diff --git a/lib/banzai/pipeline/markup_pipeline.rb b/lib/banzai/pipeline/markup_pipeline.rb new file mode 100644 index 00000000000..c56d908009f --- /dev/null +++ b/lib/banzai/pipeline/markup_pipeline.rb @@ -0,0 +1,13 @@ +module Banzai + module Pipeline + class MarkupPipeline < BasePipeline + def self.filters + @filters ||= FilterArray[ + Filter::SanitizationFilter, + Filter::ExternalLinkFilter, + Filter::PlantumlFilter + ] + end + end + end +end diff --git a/lib/gitlab/asciidoc.rb b/lib/gitlab/asciidoc.rb index d575367d81a..9ebe79a640e 100644 --- a/lib/gitlab/asciidoc.rb +++ b/lib/gitlab/asciidoc.rb @@ -30,15 +30,14 @@ module Gitlab ) asciidoc_opts[:attributes].unshift(*DEFAULT_ADOC_ATTRS) + context[:pipeline] = :markup + plantuml_setup html = ::Asciidoctor.convert(input, asciidoc_opts) - + html = Banzai.render(html, context) html = Banzai.post_process(html, context) - filter = Banzai::Filter::SanitizationFilter.new(html) - html = filter.call.to_s - html.html_safe end diff --git a/lib/gitlab/other_markup.rb b/lib/gitlab/other_markup.rb index e67acf28c94..2003ee615e5 100644 --- a/lib/gitlab/other_markup.rb +++ b/lib/gitlab/other_markup.rb @@ -14,12 +14,11 @@ module Gitlab def self.render(file_name, input, context) html = GitHub::Markup.render(file_name, input). force_encoding(input.encoding) + context[:pipeline] = :markup + html = Banzai.render(html, context) html = Banzai.post_process(html, context) - filter = Banzai::Filter::SanitizationFilter.new(html) - html = filter.call.to_s - html.html_safe end end |