]> source.dussan.org Git - redmine.git/commitdiff
Backported r15539 (#23067).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 18 Jun 2016 10:17:24 +0000 (10:17 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 18 Jun 2016 10:17:24 +0000 (10:17 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/3.1-stable@15559 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/field_format.rb
test/unit/lib/redmine/field_format/field_format_test.rb

index 979830001e8562d216c4c9843b4025c800700611..dcc26048e693c63229136e8bcb6e39dfc35382cd 100644 (file)
@@ -15,6 +15,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
+require 'uri'
+
 module Redmine
   module FieldFormat
     def self.add(name, klass)
@@ -186,7 +188,7 @@ module Redmine
             end
           end
         end
-        url
+        URI.encode(url)
       end
       protected :url_from_pattern
 
index 9864d0c41cf184cf5ebdf011f52d366d853e6aad..08e167e701796d9e2a57ba91e6007ff9ca2ecd1d 100644 (file)
@@ -59,4 +59,12 @@ class Redmine::FieldFormatTest < ActionView::TestCase
     assert_equal "bar", field.format.formatted_custom_value(self, custom_value, false)
     assert_equal '<a href="http://foo/bar">bar</a>', field.format.formatted_custom_value(self, custom_value, true)
   end
+
+  def test_text_field_with_url_pattern_and_value_containing_a_space_should_format_as_link
+    field = IssueCustomField.new(:field_format => 'string', :url_pattern => 'http://foo/%value%')
+    custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "foo bar")
+
+    assert_equal "foo bar", field.format.formatted_custom_value(self, custom_value, false)
+    assert_equal '<a href="http://foo/foo%20bar">foo bar</a>', field.format.formatted_custom_value(self, custom_value, true)
+  end
 end