##// END OF EJS Templates
Merged r2664, r2665, r2670, r2674, r2677, r2679 from trunk....
Jean-Philippe Lang -
r2589:7b699af83748
parent child
Show More
@@ -65,14 +65,20 class Attachment < ActiveRecord::Base
65 65 nil
66 66 end
67 67
68 # Copy temp file to its final location
68 # Copies the temporary file to its final location
69 # and computes its MD5 hash
69 70 def before_save
70 71 if @temp_file && (@temp_file.size > 0)
71 72 logger.debug("saving '#{self.diskfile}'")
73 md5 = Digest::MD5.new
72 74 File.open(diskfile, "wb") do |f|
73 f.write(@temp_file.read)
75 buffer = ""
76 while (buffer = @temp_file.read(8192))
77 f.write(buffer)
78 md5.update(buffer)
79 end
74 80 end
75 self.digest = self.class.digest(diskfile)
81 self.digest = md5.hexdigest
76 82 end
77 83 # Don't save the content type if it's longer than the authorized length
78 84 if self.content_type && self.content_type.length > 255
@@ -141,11 +147,4 private
141 147 end
142 148 df
143 149 end
144
145 # Returns the MD5 digest of the file at given path
146 def self.digest(filename)
147 File.open(filename, 'rb') do |f|
148 Digest::MD5.hexdigest(f.read)
149 end
150 end
151 150 end
@@ -1,6 +1,8
1 1 <h2><%=l(:label_settings)%></h2>
2 2
3 3 <% tabs = project_settings_tabs %>
4
5 <% if tabs.any? %>
4 6 <% selected_tab = params[:tab] ? params[:tab].to_s : tabs.first[:name] %>
5 7
6 8 <div class="tabs">
@@ -20,5 +22,8
20 22 :style => (tab[:name] != selected_tab ? 'display:none' : nil),
21 23 :class => 'tab-content') %>
22 24 <% end -%>
25 <% else %>
26 <p class="nodata"><%= l(:label_no_data) %></p>
27 <% end %>
23 28
24 29 <% html_title(l(:label_settings)) -%>
@@ -5,6 +5,15 Copyright (C) 2006-2009 Jean-Philippe Lang
5 5 http://www.redmine.org/
6 6
7 7
8 == 2009-xx-xx v0.8.4
9
10 * Allow textile mailto links
11 * Fixed: memory consumption when uploading file
12 * Fixed: Mercurial integration doesn't work if Redmine is installed in folder path containing space
13 * Fixed: an error is raised when no tab is available on project settings
14 * Fixed: insert image macro corrupts urls with excalamation marks
15
16
8 17 == 2009-04-05 v0.8.3
9 18
10 19 * Separate project field and subject in cross-project issue view
@@ -792,7 +792,7 class RedCloth3 < String
792 792 (?:\(([^)]+?)\)(?="))? # $title
793 793 ":
794 794 ( # $url
795 (\/|[a-zA-Z]+:\/\/|www\.) # $proto
795 (\/|[a-zA-Z]+:\/\/|www\.|mailto:) # $proto
796 796 [\w\/]\S+?
797 797 )
798 798 (\/)? # $slash
@@ -907,7 +907,7 class RedCloth3 < String
907 907 end
908 908
909 909 IMAGE_RE = /
910 (<p>|.|^) # start of line?
910 (<p>|\s|^) # start of line?
911 911 \! # opening
912 912 (\<|\=|\>)? # optional alignment atts
913 913 (#{C}) # optional style,class atts
@@ -105,7 +105,7 module Redmine
105 105 # makes Mercurial produce a xml output.
106 106 def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
107 107 revisions = Revisions.new
108 cmd = "#{HG_BIN} --debug --encoding utf8 -R #{target('')} log -C --style #{self.class.template_path}"
108 cmd = "#{HG_BIN} --debug --encoding utf8 -R #{target('')} log -C --style #{shell_quote self.class.template_path}"
109 109 if identifier_from && identifier_to
110 110 cmd << " -r #{identifier_from.to_i}:#{identifier_to.to_i}"
111 111 elsif identifier_from
@@ -22,6 +22,19 class AttachmentTest < Test::Unit::TestCase
22 22
23 23 def setup
24 24 end
25
26 def test_create
27 a = Attachment.new(:container => Issue.find(1),
28 :file => test_uploaded_file("testfile.txt", "text/plain"),
29 :author => User.find(1))
30 assert a.save
31 assert_equal 'testfile.txt', a.filename
32 assert_equal 59, a.filesize
33 assert_equal 'text/plain', a.content_type
34 assert_equal 0, a.downloads
35 assert_equal Digest::MD5.hexdigest(test_uploaded_file("testfile.txt", "text/plain").read), a.digest
36 assert File.exist?(a.diskfile)
37 end
25 38
26 39 def test_diskfilename
27 40 assert Attachment.disk_filename("test_file.txt") =~ /^\d{12}_test_file.txt$/
@@ -30,8 +43,4 class AttachmentTest < Test::Unit::TestCase
30 43 assert_equal 'f8139524ebb8f32e51976982cd20a85d', Attachment.disk_filename("test_accentué")[13..-1]
31 44 assert_equal 'cbb5b0f30978ba03731d61f9f6d10011', Attachment.disk_filename("test_accentué.ça")[13..-1]
32 45 end
33
34 def test_digest
35 assert_equal '1478adae0d4eb06d35897518540e25d6', Attachment.digest(Test::Unit::TestCase.fixture_path + "/files/testfile.txt")
36 end
37 46 end
@@ -55,6 +55,8 class ApplicationHelperTest < HelperTestCase
55 55 'ftp://foo.bar' => '<a class="external" href="ftp://foo.bar">ftp://foo.bar</a>',
56 56 'ftps://foo.bar' => '<a class="external" href="ftps://foo.bar">ftps://foo.bar</a>',
57 57 'sftp://foo.bar' => '<a class="external" href="sftp://foo.bar">sftp://foo.bar</a>',
58 # two exclamation marks
59 'http://example.net/path!602815048C7B5C20!302.html' => '<a class="external" href="http://example.net/path!602815048C7B5C20!302.html">http://example.net/path!602815048C7B5C20!302.html</a>',
58 60 }
59 61 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
60 62 end
@@ -105,7 +107,11 class ApplicationHelperTest < HelperTestCase
105 107 '"link (Link title with "double-quotes")":http://foo.bar' => '<a href="http://foo.bar" title="Link title with &quot;double-quotes&quot;" class="external">link</a>',
106 108 "This is not a \"Link\":\n\nAnother paragraph" => "This is not a \"Link\":</p>\n\n\n\t<p>Another paragraph",
107 109 # no multiline link text
108 "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<br />\nand another on a second line\":test"
110 "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<br />\nand another on a second line\":test",
111 # mailto link
112 "\"system administrator\":mailto:sysadmin@example.com?subject=redmine%20permissions" => "<a href=\"mailto:sysadmin@example.com?subject=redmine%20permissions\">system administrator</a>",
113 # two exclamation marks
114 '"a link":http://example.net/path!602815048C7B5C20!302.html' => '<a href="http://example.net/path!602815048C7B5C20!302.html" class="external">a link</a>',
109 115 }
110 116 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
111 117 end
General Comments 0
You need to be logged in to leave comments. Login now