summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVinnie Okada <vokada@mrvinn.com>2015-04-16 18:25:35 -0600
committerVinnie Okada <vokada@mrvinn.com>2015-04-17 20:39:38 -0600
commitdf9a992c1578b46d20ba3bd5df9f1e6439f6df6d (patch)
tree56798a9340ac18259ec3ff6554e383dda2e40102 /lib
parent9deda68257962e82f713d484870f22418073b367 (diff)
downloadgitlab-ce-df9a992c1578b46d20ba3bd5df9f1e6439f6df6d.tar.gz
Fix GFM extractions
Extract and re-insert links after sanitizing user markup.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/markdown.rb26
1 files changed, 13 insertions, 13 deletions
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{<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
- # 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{<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]
text = parse_tasks(text)
end