@@ -45,7 +45,7 class Changeset < ActiveRecord::Base | |||
|
45 | 45 | end |
|
46 | 46 | |
|
47 | 47 | def comments=(comment) |
|
48 |
write_attribute(:comments, |
|
|
48 | write_attribute(:comments, Changeset.normalize_comments(comment)) | |
|
49 | 49 | end |
|
50 | 50 | |
|
51 | 51 | def committed_on=(date) |
@@ -134,9 +134,14 class Changeset < ActiveRecord::Base | |||
|
134 | 134 | @next ||= Changeset.find(:first, :conditions => ['id > ? AND repository_id = ?', self.id, self.repository_id], :order => 'id ASC') |
|
135 | 135 | end |
|
136 | 136 | |
|
137 | # Strips and reencodes a commit log before insertion into the database | |
|
138 | def self.normalize_comments(str) | |
|
139 | to_utf8(str.to_s.strip) | |
|
140 | end | |
|
141 | ||
|
137 | 142 | private |
|
138 | 143 | |
|
139 | def to_utf8(str) | |
|
144 | def self.to_utf8(str) | |
|
140 | 145 | return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii |
|
141 | 146 | encoding = Setting.commit_logs_encoding.to_s.strip |
|
142 | 147 | unless encoding.blank? || encoding == 'UTF-8' |
@@ -109,7 +109,7 class Repository::Cvs < Repository | |||
|
109 | 109 | cs = changesets.find(:first, :conditions=>{ |
|
110 | 110 | :committed_on=>revision.time-time_delta..revision.time+time_delta, |
|
111 | 111 | :committer=>revision.author, |
|
112 | :comments=>revision.message | |
|
112 | :comments=>Changeset.normalize_comments(revision.message) | |
|
113 | 113 | }) |
|
114 | 114 | |
|
115 | 115 | # create a new changeset.... |
General Comments 0
You need to be logged in to leave comments.
Login now