]> source.dussan.org Git - redmine.git/commitdiff
Redmine links regexp fix (#1369, url hash turned into a ticket link).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 4 Jun 2008 21:30:12 +0000 (21:30 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 4 Jun 2008 21:30:12 +0000 (21:30 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1492 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index 589b054f32f76c25833583299828786a16cdaaa6..405c5bf44f5b9e761e3898ae37d9bf4451c2ae40 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:]]|\s|<|$)}) do |m|
       leading, esc, prefix, sep, oid = $1, $2, $3, $5 || $7, $6 || $8
       link = nil
       if esc.nil?
index 937d8aa20b144e6ccb81a49ff525571eb7c6578e..4f8ededd176f2b49733444ef6578d667a973964a 100644 (file)
@@ -108,7 +108,9 @@ class ApplicationHelperTest < HelperTestCase
       '!version:"1.0"'              => 'version:"1.0"',
       '!source:/some/file'          => 'source:/some/file',
       # invalid expressions
-      'source:'                     => 'source:'
+      'source:'                     => 'source:',
+      # url hash
+      "http://foo.bar/FAQ#3"       => '<a class="external" href="http://foo.bar/FAQ#3">http://foo.bar/FAQ#3</a>',
     }
     @project = Project.find(1)
     to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }