Commit 59e3832b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets Committed by Dmitriy Zaporozhets

Merge branch 'fix-label-color' into 'master'

Parse GFM references after sanitizing

Parse GFM references - labels, issues, MRs, etc. - after calling the HTML Pipeline `SanitizationFilter` so that we can use non-whitelisted attributes like `style`.  See #2188.

See merge request !1745
parent 5bbd2b8c
...@@ -68,23 +68,8 @@ module Gitlab ...@@ -68,23 +68,8 @@ module Gitlab
@options = options @options = options
@html_options = html_options @html_options = html_options
# Extract pre blocks so they are not altered
# from http://github.github.com/github-flavored-markdown/
text.gsub!(%r{<pre>.*?</pre>|<code>.*?</code>}m) { |match| extract_piece(match) }
# Extract links with probably parsable hrefs
text.gsub!(%r{<a.*?>.*?</a>}m) { |match| extract_piece(match) }
# Extract images with probably parsable src
text.gsub!(%r{<img.*?>}m) { |match| extract_piece(match) }
# TODO: add popups with additional information # TODO: add popups with additional information
text = parse(text, project)
# Insert pre block extractions
text.gsub!(/\{gfm-extraction-(\h{32})\}/) do
insert_piece($1)
end
# Used markdown pipelines in GitLab: # Used markdown pipelines in GitLab:
# GitlabEmojiFilter - performs emoji replacement. # GitlabEmojiFilter - performs emoji replacement.
# SanitizationFilter - remove unsafe HTML tags and attributes # SanitizationFilter - remove unsafe HTML tags and attributes
...@@ -129,6 +114,21 @@ module Gitlab ...@@ -129,6 +114,21 @@ module Gitlab
text = result[:output].to_html(save_with: save_options) text = result[:output].to_html(save_with: save_options)
# Extract pre blocks so they are not altered
# from http://github.github.com/github-flavored-markdown/
text.gsub!(%r{<pre>.*?</pre>|<code>.*?</code>}m) { |match| extract_piece(match) }
# Extract links with probably parsable hrefs
text.gsub!(%r{<a.*?>.*?</a>}m) { |match| extract_piece(match) }
# Extract images with probably parsable src
text.gsub!(%r{<img.*?>}m) { |match| extract_piece(match) }
text = parse(text, project)
# Insert pre block extractions
text.gsub!(/\{gfm-extraction-(\h{32})\}/) do
insert_piece($1)
end
if options[:parse_tasks] if options[:parse_tasks]
text = parse_tasks(text) text = parse_tasks(text)
end end
...@@ -150,7 +150,7 @@ module Gitlab ...@@ -150,7 +150,7 @@ module Gitlab
@extractions[id] @extractions[id]
end end
# Private: Parses text for references and emoji # Private: Parses text for references
# #
# text - Text to parse # text - Text to parse
# #
......
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