From 9deda68257962e82f713d484870f22418073b367 Mon Sep 17 00:00:00 2001 From: Vinnie Okada Date: Sat, 28 Mar 2015 08:58:30 -0600 Subject: 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`. --- lib/gitlab/markdown.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index 41bb8d08924..48a589db837 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -70,8 +70,6 @@ module Gitlab # TODO: add popups with additional information - text = parse(text, project) - # Insert pre block extractions text.gsub!(/\{gfm-extraction-(\h{32})\}/) do insert_piece($1) @@ -120,6 +118,8 @@ module Gitlab text = result[:output].to_html(save_with: saveoptions) + text = parse(text, project) + if options[:parse_tasks] text = parse_tasks(text) end @@ -141,7 +141,7 @@ module Gitlab @extractions[id] end - # Private: Parses text for references and emoji + # Private: Parses text for references # # text - Text to parse # -- cgit v1.2.1 From df9a992c1578b46d20ba3bd5df9f1e6439f6df6d Mon Sep 17 00:00:00 2001 From: Vinnie Okada Date: Thu, 16 Apr 2015 18:25:35 -0600 Subject: Fix GFM extractions Extract and re-insert links after sanitizing user markup. --- lib/gitlab/markdown.rb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index 48a589db837..b10e85e8a8c 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -60,21 +60,8 @@ module Gitlab @html_options = html_options - # Extract pre blocks so they are not altered - # from http://github.github.com/github-flavored-markdown/ - text.gsub!(%r{
.*?
|.*?}m) { |match| extract_piece(match) } - # Extract links with probably parsable hrefs - text.gsub!(%r{.*?}m) { |match| extract_piece(match) } - # Extract images with probably parsable src - text.gsub!(%r{}m) { |match| extract_piece(match) } - # TODO: add popups with additional information - # Insert pre block extractions - text.gsub!(/\{gfm-extraction-(\h{32})\}/) do - insert_piece($1) - end - # Used markdown pipelines in GitLab: # GitlabEmojiFilter - performs emoji replacement. # SanitizationFilter - remove unsafe HTML tags and attributes @@ -118,8 +105,21 @@ module Gitlab text = result[:output].to_html(save_with: saveoptions) + # Extract pre blocks so they are not altered + # from http://github.github.com/github-flavored-markdown/ + text.gsub!(%r{
.*?
|.*?}m) { |match| extract_piece(match) } + # Extract links with probably parsable hrefs + text.gsub!(%r{.*?}m) { |match| extract_piece(match) } + # Extract images with probably parsable src + text.gsub!(%r{}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] text = parse_tasks(text) end -- cgit v1.2.1