@@ -29,7 +29,13 module AttachmentsHelper | |||
|
29 | 29 | end |
|
30 | 30 | |
|
31 | 31 | def to_utf8(str) |
|
32 | return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii | |
|
32 | if str.respond_to?(:force_encoding) | |
|
33 | str.force_encoding('UTF-8') | |
|
34 | return str if str.valid_encoding? | |
|
35 | else | |
|
36 | return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii | |
|
37 | end | |
|
38 | ||
|
33 | 39 | begin |
|
34 | 40 | Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-3] |
|
35 | 41 | rescue Iconv::InvalidEncoding |
@@ -113,7 +113,13 module RepositoriesHelper | |||
|
113 | 113 | end |
|
114 | 114 | |
|
115 | 115 | def to_utf8(str) |
|
116 | return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii | |
|
116 | if str.respond_to?(:force_encoding) | |
|
117 | str.force_encoding('UTF-8') | |
|
118 | return str if str.valid_encoding? | |
|
119 | else | |
|
120 | return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii | |
|
121 | end | |
|
122 | ||
|
117 | 123 | @encodings ||= Setting.repositories_encodings.split(',').collect(&:strip) |
|
118 | 124 | @encodings.each do |encoding| |
|
119 | 125 | begin |
@@ -227,7 +227,13 class Changeset < ActiveRecord::Base | |||
|
227 | 227 | end |
|
228 | 228 | |
|
229 | 229 | def self.to_utf8(str) |
|
230 | return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii | |
|
230 | if str.respond_to?(:force_encoding) | |
|
231 | str.force_encoding('UTF-8') | |
|
232 | return str if str.valid_encoding? | |
|
233 | else | |
|
234 | return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii | |
|
235 | end | |
|
236 | ||
|
231 | 237 | encoding = Setting.commit_logs_encoding.to_s.strip |
|
232 | 238 | unless encoding.blank? || encoding == 'UTF-8' |
|
233 | 239 | begin |
General Comments 0
You need to be logged in to leave comments.
Login now