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