Skip to content
Snippets Groups Projects
Commit d313a768 authored by Douwe Maan's avatar Douwe Maan
Browse files

Explicitly only parse references by specified filter

parent d6fb96b9
No related branches found
No related tags found
1 merge request!1090Separate rendering of Markdown reference links from redacting those the user doesn't have access to and extracting referenced objects
Pipeline #
Loading
@@ -33,6 +33,8 @@ module Gitlab
Loading
@@ -33,6 +33,8 @@ module Gitlab
reference_type = node.attr('data-reference-filter') reference_type = node.attr('data-reference-filter')
reference_filter = reference_type.constantize reference_filter = reference_type.constantize
   
return if context[:reference_filter] && reference_filter != context[:reference_filter]
return unless reference_filter.user_can_reference?(current_user, node, context) return unless reference_filter.user_can_reference?(current_user, node, context)
   
references = reference_filter.referenced_by(node) references = reference_filter.referenced_by(node)
Loading
Loading
Loading
@@ -40,16 +40,20 @@ module Gitlab
Loading
@@ -40,16 +40,20 @@ module Gitlab
# #
# Returns the results Array for the requested filter type # Returns the results Array for the requested filter type
def pipeline_result(filter_type) def pipeline_result(filter_type)
klass = filter_type.to_s.camelize + 'ReferenceFilter' klass = "#{filter_type.to_s.camelize}ReferenceFilter"
filter = Gitlab::Markdown.const_get(klass) filter = Gitlab::Markdown.const_get(klass)
   
context = { context = {
project: project, project: project,
current_user: current_user, current_user: current_user,
# We don't actually care about the links generated # We don't actually care about the links generated
only_path: true, only_path: true,
ignore_blockquotes: true, ignore_blockquotes: true,
load_lazy_references: false
# ReferenceGathererFilter
load_lazy_references: false,
reference_filter: filter
} }
   
pipeline = HTML::Pipeline.new([filter, Gitlab::Markdown::ReferenceGathererFilter], context) pipeline = HTML::Pipeline.new([filter, Gitlab::Markdown::ReferenceGathererFilter], context)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment