Commit 5dd77358 authored by Douwe Maan's avatar Douwe Maan

Pass project to RedactorFilter

parent 9d066bc9
...@@ -59,7 +59,7 @@ module GitlabMarkdownHelper ...@@ -59,7 +59,7 @@ module GitlabMarkdownHelper
user = current_user if defined?(current_user) user = current_user if defined?(current_user)
html = Gitlab::Markdown.render(text, context) html = Gitlab::Markdown.render(text, context)
Gitlab::Markdown.post_process(html, pipeline: context[:pipeline], user: user) Gitlab::Markdown.post_process(html, pipeline: context[:pipeline], project: @project, user: user)
end end
# TODO (rspeicher): Remove all usages of this helper and just call `markdown` # TODO (rspeicher): Remove all usages of this helper and just call `markdown`
...@@ -78,7 +78,7 @@ module GitlabMarkdownHelper ...@@ -78,7 +78,7 @@ module GitlabMarkdownHelper
user = current_user if defined?(current_user) user = current_user if defined?(current_user)
html = Gitlab::Markdown.gfm(text, options) html = Gitlab::Markdown.gfm(text, options)
Gitlab::Markdown.post_process(html, pipeline: options[:pipeline], user: user) Gitlab::Markdown.post_process(html, pipeline: options[:pipeline], project: @project, user: user)
end end
def asciidoc(text) def asciidoc(text)
......
...@@ -47,12 +47,17 @@ module Gitlab ...@@ -47,12 +47,17 @@ module Gitlab
# #
# html - String to process # html - String to process
# options - Hash of options to customize output # options - Hash of options to customize output
# :pipeline - Symbol pipeline type # :pipeline - Symbol pipeline type
# :user - User object # :project - Project
# :user - User object
# #
# Returns an HTML-safe String # Returns an HTML-safe String
def self.post_process(html, options) def self.post_process(html, options)
doc = post_processor.to_document(html, current_user: options[:user]) context = {
project: options[:project],
current_user: options[:user]
}
doc = post_processor.to_document(html, context)
if options[:pipeline] == :atom if options[:pipeline] == :atom
doc.to_html(save_with: Nokogiri::XML::Node::SaveOptions::AS_XHTML) doc.to_html(save_with: Nokogiri::XML::Node::SaveOptions::AS_XHTML)
......
...@@ -15,7 +15,7 @@ module Gitlab ...@@ -15,7 +15,7 @@ module Gitlab
def self.user_can_reference?(user, node, context) def self.user_can_reference?(user, node, context)
if node.has_attribute?('data-project') if node.has_attribute?('data-project')
project_id = node.attr('data-project').to_i project_id = node.attr('data-project').to_i
return true if project_id == context[:project].id return true if project_id == context[:project].try(:id)
project = Project.find(project_id) rescue nil project = Project.find(project_id) rescue nil
Ability.abilities.allowed?(user, :read_project, project) Ability.abilities.allowed?(user, :read_project, project)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment