From 7b699af8374864e4776e5cfec7478021ddde1bfe Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 24 Apr 2009 16:13:35 +0000 Subject: [PATCH] Merged r2664, r2665, r2670, r2674, r2677, r2679 from trunk. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.8-stable@2681 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/attachment.rb | 19 +++++++++---------- app/views/projects/settings.rhtml | 5 +++++ doc/CHANGELOG | 9 +++++++++ lib/redcloth3.rb | 4 ++-- lib/redmine/scm/adapters/mercurial_adapter.rb | 2 +- test/unit/attachment_test.rb | 17 +++++++++++++---- test/unit/helpers/application_helper_test.rb | 8 +++++++- 7 files changed, 46 insertions(+), 18 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 2957b9dd1..7d34a3bc8 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -65,14 +65,20 @@ class Attachment < ActiveRecord::Base nil end - # Copy temp file to its final location + # Copies the temporary file to its final location + # and computes its MD5 hash def before_save if @temp_file && (@temp_file.size > 0) logger.debug("saving '#{self.diskfile}'") + md5 = Digest::MD5.new File.open(diskfile, "wb") do |f| - f.write(@temp_file.read) + buffer = "" + while (buffer = @temp_file.read(8192)) + f.write(buffer) + md5.update(buffer) + end end - self.digest = self.class.digest(diskfile) + self.digest = md5.hexdigest end # Don't save the content type if it's longer than the authorized length if self.content_type && self.content_type.length > 255 @@ -141,11 +147,4 @@ private end df end - - # Returns the MD5 digest of the file at given path - def self.digest(filename) - File.open(filename, 'rb') do |f| - Digest::MD5.hexdigest(f.read) - end - end end diff --git a/app/views/projects/settings.rhtml b/app/views/projects/settings.rhtml index c7b0f5006..e8be1a091 100644 --- a/app/views/projects/settings.rhtml +++ b/app/views/projects/settings.rhtml @@ -1,6 +1,8 @@

<%=l(:label_settings)%>

<% tabs = project_settings_tabs %> + +<% if tabs.any? %> <% selected_tab = params[:tab] ? params[:tab].to_s : tabs.first[:name] %>
@@ -20,5 +22,8 @@ :style => (tab[:name] != selected_tab ? 'display:none' : nil), :class => 'tab-content') %> <% end -%> +<% else %> +

<%= l(:label_no_data) %>

+<% end %> <% html_title(l(:label_settings)) -%> diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 35d515c6d..4ebc41c46 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -5,6 +5,15 @@ Copyright (C) 2006-2009 Jean-Philippe Lang http://www.redmine.org/ +== 2009-xx-xx v0.8.4 + +* Allow textile mailto links +* Fixed: memory consumption when uploading file +* Fixed: Mercurial integration doesn't work if Redmine is installed in folder path containing space +* Fixed: an error is raised when no tab is available on project settings +* Fixed: insert image macro corrupts urls with excalamation marks + + == 2009-04-05 v0.8.3 * Separate project field and subject in cross-project issue view diff --git a/lib/redcloth3.rb b/lib/redcloth3.rb index 9e63bf5ac..a4d33f804 100644 --- a/lib/redcloth3.rb +++ b/lib/redcloth3.rb @@ -792,7 +792,7 @@ class RedCloth3 < String (?:\(([^)]+?)\)(?="))? # $title ": ( # $url - (\/|[a-zA-Z]+:\/\/|www\.) # $proto + (\/|[a-zA-Z]+:\/\/|www\.|mailto:) # $proto [\w\/]\S+? ) (\/)? # $slash @@ -907,7 +907,7 @@ class RedCloth3 < String end IMAGE_RE = / - (

|.|^) # start of line? + (

|\s|^) # start of line? \! # opening (\<|\=|\>)? # optional alignment atts (#{C}) # optional style,class atts diff --git a/lib/redmine/scm/adapters/mercurial_adapter.rb b/lib/redmine/scm/adapters/mercurial_adapter.rb index 4eed776d8..ee7d7ea9d 100644 --- a/lib/redmine/scm/adapters/mercurial_adapter.rb +++ b/lib/redmine/scm/adapters/mercurial_adapter.rb @@ -105,7 +105,7 @@ module Redmine # makes Mercurial produce a xml output. def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}) revisions = Revisions.new - cmd = "#{HG_BIN} --debug --encoding utf8 -R #{target('')} log -C --style #{self.class.template_path}" + cmd = "#{HG_BIN} --debug --encoding utf8 -R #{target('')} log -C --style #{shell_quote self.class.template_path}" if identifier_from && identifier_to cmd << " -r #{identifier_from.to_i}:#{identifier_to.to_i}" elsif identifier_from diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb index a8c533238..ae92991f8 100644 --- a/test/unit/attachment_test.rb +++ b/test/unit/attachment_test.rb @@ -22,6 +22,19 @@ class AttachmentTest < Test::Unit::TestCase def setup end + + def test_create + a = Attachment.new(:container => Issue.find(1), + :file => test_uploaded_file("testfile.txt", "text/plain"), + :author => User.find(1)) + assert a.save + assert_equal 'testfile.txt', a.filename + assert_equal 59, a.filesize + assert_equal 'text/plain', a.content_type + assert_equal 0, a.downloads + assert_equal Digest::MD5.hexdigest(test_uploaded_file("testfile.txt", "text/plain").read), a.digest + assert File.exist?(a.diskfile) + end def test_diskfilename assert Attachment.disk_filename("test_file.txt") =~ /^\d{12}_test_file.txt$/ @@ -30,8 +43,4 @@ class AttachmentTest < Test::Unit::TestCase assert_equal 'f8139524ebb8f32e51976982cd20a85d', Attachment.disk_filename("test_accentué")[13..-1] assert_equal 'cbb5b0f30978ba03731d61f9f6d10011', Attachment.disk_filename("test_accentué.ça")[13..-1] end - - def test_digest - assert_equal '1478adae0d4eb06d35897518540e25d6', Attachment.digest(Test::Unit::TestCase.fixture_path + "/files/testfile.txt") - end end diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 03a4db34d..28d2ee495 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -55,6 +55,8 @@ class ApplicationHelperTest < HelperTestCase 'ftp://foo.bar' => 'ftp://foo.bar', 'ftps://foo.bar' => 'ftps://foo.bar', 'sftp://foo.bar' => 'sftp://foo.bar', + # two exclamation marks + 'http://example.net/path!602815048C7B5C20!302.html' => 'http://example.net/path!602815048C7B5C20!302.html', } to_test.each { |text, result| assert_equal "

#{result}

", textilizable(text) } end @@ -105,7 +107,11 @@ class ApplicationHelperTest < HelperTestCase '"link (Link title with "double-quotes")":http://foo.bar' => 'link', "This is not a \"Link\":\n\nAnother paragraph" => "This is not a \"Link\":

\n\n\n\t

Another paragraph", # no multiline link text - "This is a double quote \"on the first line\nand another on a second line\":test" => "This is a double quote \"on the first line
\nand another on a second line\":test" + "This is a double quote \"on the first line\nand another on a second line\":test" => "This is a double quote \"on the first line
\nand another on a second line\":test", + # mailto link + "\"system administrator\":mailto:sysadmin@example.com?subject=redmine%20permissions" => "system administrator", + # two exclamation marks + '"a link":http://example.net/path!602815048C7B5C20!302.html' => 'a link', } to_test.each { |text, result| assert_equal "

#{result}

", textilizable(text) } end -- 2.39.5