@@ -754,8 +754,11 module ApplicationHelper | |||||
754 | # identifier:version:1.0.0 |
|
754 | # identifier:version:1.0.0 | |
755 | # identifier:source:some/file |
|
755 | # identifier:source:some/file | |
756 | def parse_redmine_links(text, default_project, obj, attr, only_path, options) |
|
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| |
|
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 |
leading, esc, project_prefix, project_identifier, prefix, repo_prefix, repo_identifier, sep, identifier, comment_suffix, comment_id = $1, |
|
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 | link = nil |
|
762 | link = nil | |
760 | project = default_project |
|
763 | project = default_project | |
761 | if project_identifier |
|
764 | if project_identifier | |
@@ -894,6 +897,7 module ApplicationHelper | |||||
894 | (leading + (link || "#{project_prefix}#{prefix}#{repo_prefix}#{sep}#{identifier}#{comment_suffix}")) |
|
897 | (leading + (link || "#{project_prefix}#{prefix}#{repo_prefix}#{sep}#{identifier}#{comment_suffix}")) | |
895 | end |
|
898 | end | |
896 | end |
|
899 | end | |
|
900 | end | |||
897 |
|
901 | |||
898 | HEADING_RE = /(<h(\d)( [^>]+)?>(.+?)<\/h(\d)>)/i unless const_defined?(:HEADING_RE) |
|
902 | HEADING_RE = /(<h(\d)( [^>]+)?>(.+?)<\/h(\d)>)/i unless const_defined?(:HEADING_RE) | |
899 |
|
903 |
@@ -363,6 +363,12 RAW | |||||
363 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text), "#{text} failed" } |
|
363 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text), "#{text} failed" } | |
364 | end |
|
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 | def test_redmine_links_with_a_different_project_before_current_project |
|
372 | def test_redmine_links_with_a_different_project_before_current_project | |
367 | vp1 = Version.generate!(:project_id => 1, :name => '1.4.4') |
|
373 | vp1 = Version.generate!(:project_id => 1, :name => '1.4.4') | |
368 | vp3 = Version.generate!(:project_id => 3, :name => '1.4.4') |
|
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