@@ -0,0 +1,1 | |||||
|
1 | Texte encod� en ISO-8859-1. No newline at end of file |
@@ -1,5 +1,5 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 |
# Copyright (C) 2006-200 |
|
2 | # Copyright (C) 2006-2010 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
@@ -57,6 +57,10 class Changeset < ActiveRecord::Base | |||||
57 | super |
|
57 | super | |
58 | end |
|
58 | end | |
59 |
|
59 | |||
|
60 | def committer=(arg) | |||
|
61 | write_attribute(:committer, self.class.to_utf8(arg.to_s)) | |||
|
62 | end | |||
|
63 | ||||
60 | def project |
|
64 | def project | |
61 | repository.project |
|
65 | repository.project | |
62 | end |
|
66 | end | |
@@ -180,11 +184,12 class Changeset < ActiveRecord::Base | |||||
180 | encoding = Setting.commit_logs_encoding.to_s.strip |
|
184 | encoding = Setting.commit_logs_encoding.to_s.strip | |
181 | unless encoding.blank? || encoding == 'UTF-8' |
|
185 | unless encoding.blank? || encoding == 'UTF-8' | |
182 | begin |
|
186 | begin | |
183 |
|
|
187 | str = Iconv.conv('UTF-8', encoding, str) | |
184 | rescue Iconv::Failure |
|
188 | rescue Iconv::Failure | |
185 | # do nothing here |
|
189 | # do nothing here | |
186 | end |
|
190 | end | |
187 | end |
|
191 | end | |
188 | str |
|
192 | # removes invalid UTF8 sequences | |
|
193 | Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-3] | |||
189 | end |
|
194 | end | |
190 | end |
|
195 | end |
@@ -1,5 +1,7 | |||||
1 | # redMine - project management software |
|
1 | # encoding: utf-8 | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # | |
|
3 | # Redmine - project management software | |||
|
4 | # Copyright (C) 2006-2010 Jean-Philippe Lang | |||
3 | # |
|
5 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
6 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
7 | # modify it under the terms of the GNU General Public License | |
@@ -117,4 +119,18 class ChangesetTest < ActiveSupport::TestCase | |||||
117 | changeset = Changeset.find_by_revision('10') |
|
119 | changeset = Changeset.find_by_revision('10') | |
118 | assert_nil changeset.next |
|
120 | assert_nil changeset.next | |
119 | end |
|
121 | end | |
|
122 | ||||
|
123 | def test_comments_should_be_converted_to_utf8 | |||
|
124 | with_settings :commit_logs_encoding => 'ISO-8859-1' do | |||
|
125 | c = Changeset.new | |||
|
126 | c.comments = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt") | |||
|
127 | assert_equal "Texte encodé en ISO-8859-1.", c.comments | |||
|
128 | end | |||
|
129 | end | |||
|
130 | ||||
|
131 | def test_invalid_utf8_sequences_in_comments_should_be_stripped | |||
|
132 | c = Changeset.new | |||
|
133 | c.comments = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt") | |||
|
134 | assert_equal "Texte encod en ISO-8859-1.", c.comments | |||
|
135 | end | |||
120 | end |
|
136 | end |
General Comments 0
You need to be logged in to leave comments.
Login now