##// END OF EJS Templates
Fixed that Redmine links should not be parsed inside links (#18301)....
Jean-Philippe Lang -
r13214:eac3b2b27def
parent child
Show More
@@ -754,8 +754,11 module ApplicationHelper
754 754 # identifier:version:1.0.0
755 755 # identifier:source:some/file
756 756 def parse_redmine_links(text, default_project, obj, attr, only_path, options)
757 text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-_]+):)?(attachment|document|version|forum|news|message|project|commit|source|export)?(((#)|((([a-z0-9\-_]+)\|)?(r)))((\d+)((#note)?-(\d+))?)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]][^A-Za-z0-9_/])|,|\s|\]|<|$)}) do |m|
758 leading, esc, project_prefix, project_identifier, prefix, repo_prefix, repo_identifier, sep, identifier, comment_suffix, comment_id = $1, $2, $3, $4, $5, $10, $11, $8 || $12 || $18, $14 || $19, $15, $17
757 text.gsub!(%r{<a( [^>]+?)?>(.*?)</a>|([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-_]+):)?(attachment|document|version|forum|news|message|project|commit|source|export)?(((#)|((([a-z0-9\-_]+)\|)?(r)))((\d+)((#note)?-(\d+))?)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]][^A-Za-z0-9_/])|,|\s|\]|<|$)}) do |m|
758 tag_content, leading, esc, project_prefix, project_identifier, prefix, repo_prefix, repo_identifier, sep, identifier, comment_suffix, comment_id = $1, $3, $4, $5, $6, $7, $12, $13, $10 || $14 || $20, $16 || $21, $17, $19
759 if tag_content
760 $&
761 else
759 762 link = nil
760 763 project = default_project
761 764 if project_identifier
@@ -894,6 +897,7 module ApplicationHelper
894 897 (leading + (link || "#{project_prefix}#{prefix}#{repo_prefix}#{sep}#{identifier}#{comment_suffix}"))
895 898 end
896 899 end
900 end
897 901
898 902 HEADING_RE = /(<h(\d)( [^>]+)?>(.+?)<\/h(\d)>)/i unless const_defined?(:HEADING_RE)
899 903
@@ -363,6 +363,12 RAW
363 363 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text), "#{text} failed" }
364 364 end
365 365
366 def test_should_not_parse_redmine_links_inside_link
367 raw = "r1 should not be parsed in http://example.com/url-r1/"
368 assert_match %r{<p><a class="changeset".*>r1</a> should not be parsed in <a class="external" href="http://example.com/url-r1/">http://example.com/url-r1/</a></p>},
369 textilizable(raw, :project => Project.find(1))
370 end
371
366 372 def test_redmine_links_with_a_different_project_before_current_project
367 373 vp1 = Version.generate!(:project_id => 1, :name => '1.4.4')
368 374 vp3 = Version.generate!(:project_id => 3, :name => '1.4.4')
General Comments 0
You need to be logged in to leave comments. Login now