summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-08-26 12:28:15 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-08-26 12:28:15 +0000
commitd611339baaf3bc147956155897dfc21aac59dcf2 (patch)
tree8e66354684947bd4fa1be432457664950d4b06bc /app
parent0cf15476a35bfada850efc07eb78bc2bb041a8e6 (diff)
downloadredmine-d611339baaf3bc147956155897dfc21aac59dcf2.tar.gz
redmine-d611339baaf3bc147956155897dfc21aac59dcf2.zip
Fixes error with CVS+Postgresql and non-UTF8 commit logs (#917, #1659).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1768 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/models/changeset.rb9
-rw-r--r--app/models/repository/cvs.rb2
2 files changed, 8 insertions, 3 deletions
diff --git a/app/models/changeset.rb b/app/models/changeset.rb
index 656c67544..c4258c88b 100644
--- a/app/models/changeset.rb
+++ b/app/models/changeset.rb
@@ -45,7 +45,7 @@ class Changeset < ActiveRecord::Base
end
def comments=(comment)
- write_attribute(:comments, to_utf8(comment.to_s.strip))
+ write_attribute(:comments, Changeset.normalize_comments(comment))
end
def committed_on=(date)
@@ -134,9 +134,14 @@ class Changeset < ActiveRecord::Base
@next ||= Changeset.find(:first, :conditions => ['id > ? AND repository_id = ?', self.id, self.repository_id], :order => 'id ASC')
end
+ # Strips and reencodes a commit log before insertion into the database
+ def self.normalize_comments(str)
+ to_utf8(str.to_s.strip)
+ end
+
private
- def to_utf8(str)
+ def self.to_utf8(str)
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
encoding = Setting.commit_logs_encoding.to_s.strip
unless encoding.blank? || encoding == 'UTF-8'
diff --git a/app/models/repository/cvs.rb b/app/models/repository/cvs.rb
index dd9d35c8f..82082b3d6 100644
--- a/app/models/repository/cvs.rb
+++ b/app/models/repository/cvs.rb
@@ -109,7 +109,7 @@ class Repository::Cvs < Repository
cs = changesets.find(:first, :conditions=>{
:committed_on=>revision.time-time_delta..revision.time+time_delta,
:committer=>revision.author,
- :comments=>revision.message
+ :comments=>Changeset.normalize_comments(revision.message)
})
# create a new changeset....