Defect #834 » cvs.diff
/Users/siuying/Documents/workspace/redmine-trunk/app/models/repository/cvs.rb (working copy) | ||
---|---|---|
17 | 17 |
|
18 | 18 |
require 'redmine/scm/adapters/cvs_adapter' |
19 | 19 |
require 'digest/sha1' |
20 |
require 'iconv' |
|
20 | 21 |
|
21 | 22 |
class Repository::Cvs < Repository |
22 | 23 |
validates_presence_of :url, :root_url |
... | ... | |
103 | 104 |
cs = changesets.find(:first, :conditions=>{ |
104 | 105 |
:committed_on=>revision.time-time_delta..revision.time+time_delta, |
105 | 106 |
:committer=>revision.author, |
106 |
:comments=>revision.message
|
|
107 |
:comments=>fix_corrupt_encode(revision.message)
|
|
107 | 108 |
}) |
108 | 109 |
|
109 | 110 |
# create a new changeset.... |
... | ... | |
115 | 116 |
:revision => "_#{tmp_rev_num}", |
116 | 117 |
:committer => revision.author, |
117 | 118 |
:committed_on => revision.time, |
118 |
:comments => revision.message)
|
|
119 |
:comments => fix_corrupt_encode(revision.message))
|
|
119 | 120 |
tmp_rev_num += 1 |
120 | 121 |
end |
121 | 122 |
|
... | ... | |
145 | 146 |
end |
146 | 147 |
|
147 | 148 |
private |
149 |
def fix_corrupt_encode(untrusted_string) |
|
150 |
Iconv.new('UTF-8//IGNORE', 'UTF-8').iconv(untrusted_string + ' ')[0..-2] |
|
151 |
end |
|
148 | 152 |
|
149 | 153 |
# Returns the next revision number to assign to a CVS changeset |
150 | 154 |
def next_revision_number |
... | ... | |
152 | 156 |
@current_revision_number ||= (connection.select_values("SELECT revision FROM #{Changeset.table_name} WHERE repository_id = #{id} AND revision NOT LIKE '_%'").collect(&:to_i).max || 0) |
153 | 157 |
@current_revision_number += 1 |
154 | 158 |
end |
155 |
end |
|
159 |
end |