##// END OF EJS Templates
Fixes error with CVS+Postgresql and non-UTF8 commit logs (#917, #1659)....
Jean-Philippe Lang -
r1767:d611339baaf3
parent child
Show More
@@ -45,7 +45,7 class Changeset < ActiveRecord::Base
45 end
45 end
46
46
47 def comments=(comment)
47 def comments=(comment)
48 write_attribute(:comments, to_utf8(comment.to_s.strip))
48 write_attribute(:comments, Changeset.normalize_comments(comment))
49 end
49 end
50
50
51 def committed_on=(date)
51 def committed_on=(date)
@@ -134,9 +134,14 class Changeset < ActiveRecord::Base
134 @next ||= Changeset.find(:first, :conditions => ['id > ? AND repository_id = ?', self.id, self.repository_id], :order => 'id ASC')
134 @next ||= Changeset.find(:first, :conditions => ['id > ? AND repository_id = ?', self.id, self.repository_id], :order => 'id ASC')
135 end
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 private
142 private
138
143
139 def to_utf8(str)
144 def self.to_utf8(str)
140 return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
145 return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
141 encoding = Setting.commit_logs_encoding.to_s.strip
146 encoding = Setting.commit_logs_encoding.to_s.strip
142 unless encoding.blank? || encoding == 'UTF-8'
147 unless encoding.blank? || encoding == 'UTF-8'
@@ -109,7 +109,7 class Repository::Cvs < Repository
109 cs = changesets.find(:first, :conditions=>{
109 cs = changesets.find(:first, :conditions=>{
110 :committed_on=>revision.time-time_delta..revision.time+time_delta,
110 :committed_on=>revision.time-time_delta..revision.time+time_delta,
111 :committer=>revision.author,
111 :committer=>revision.author,
112 :comments=>revision.message
112 :comments=>Changeset.normalize_comments(revision.message)
113 })
113 })
114
114
115 # create a new changeset....
115 # create a new changeset....
General Comments 0
You need to be logged in to leave comments. Login now