]> source.dussan.org Git - redmine.git/commitdiff
Fixed: trailing period should not be included in redmine links of type class:id ...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 10 Jul 2008 13:36:28 +0000 (13:36 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 10 Jul 2008 13:36:28 +0000 (13:36 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1650 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
test/unit/helpers/application_helper_test.rb

index 6266dd9516dc32059569f8f1a25c22c58639c2ee..ad4c46440408ff00b6fde76893eed656f71382cb 100644 (file)
@@ -298,7 +298,7 @@ module ApplicationHelper
     #     source:some/file#L120 -> Link to line 120 of the file
     #     source:some/file@52#L120 -> Link to line 120 of the file's revision 52
     #     export:some/file -> Force the download of the file
-    text = text.gsub(%r{([\s\(,\-\>]|^)(!)?(attachment|document|version|commit|source|export)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*|"[^"]+"))(?=[[:punct:]]|\s|<|$)}) do |m|
+    text = text.gsub(%r{([\s\(,\-\>]|^)(!)?(attachment|document|version|commit|source|export)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|\s|<|$)}) do |m|
       leading, esc, prefix, sep, oid = $1, $2, $3, $5 || $7, $6 || $8
       link = nil
       if esc.nil?
index d4f9e024799af67477cb6eaec6db696167caf089..56a36851b3e1ab55cc523d90cfd102bc75e6b6b8 100644 (file)
@@ -82,6 +82,7 @@ class ApplicationHelperTest < HelperTestCase
                                   :class => 'version')
 
     source_url = {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => ['some', 'file']}
+    source_url_with_ext = {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => ['some', 'file.ext']}
     
     to_test = {
       # tickets
@@ -97,8 +98,15 @@ class ApplicationHelperTest < HelperTestCase
       'version:"1.0"'               => version_link,
       # source
       'source:/some/file'           => link_to('source:/some/file', source_url, :class => 'source'),
+      'source:/some/file.'          => link_to('source:/some/file', source_url, :class => 'source') + ".",
+      'source:/some/file.ext.'      => link_to('source:/some/file.ext', source_url_with_ext, :class => 'source') + ".",
+      'source:/some/file. '         => link_to('source:/some/file', source_url, :class => 'source') + ".",
+      'source:/some/file.ext. '     => link_to('source:/some/file.ext', source_url_with_ext, :class => 'source') + ".",
+      'source:/some/file, '         => link_to('source:/some/file', source_url, :class => 'source') + ",",
       'source:/some/file@52'        => link_to('source:/some/file@52', source_url.merge(:rev => 52), :class => 'source'),
+      'source:/some/file.ext@52'    => link_to('source:/some/file.ext@52', source_url_with_ext.merge(:rev => 52), :class => 'source'),
       'source:/some/file#L110'      => link_to('source:/some/file#L110', source_url.merge(:anchor => 'L110'), :class => 'source'),
+      'source:/some/file.ext#L110'  => link_to('source:/some/file.ext#L110', source_url_with_ext.merge(:anchor => 'L110'), :class => 'source'),
       'source:/some/file@52#L110'   => link_to('source:/some/file@52#L110', source_url.merge(:rev => 52, :anchor => 'L110'), :class => 'source'),
       'export:/some/file'           => link_to('export:/some/file', source_url.merge(:format => 'raw'), :class => 'source download'),
       # escaping