Quellcode durchsuchen

Adds support for commit logs reencoding to UTF-8 before insertion in the database (#834, #917, #1663).

Source encoding of commit logs can be selected in Application settings -> Repositories.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1767 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/0.8.0-RC1
Jean-Philippe Lang vor 16 Jahren
Ursprung
Commit
0cf15476a3
31 geänderte Dateien mit 90 neuen und 1 gelöschten Zeilen
  1. 18
    1
      app/models/changeset.rb
  2. 39
    0
      app/models/setting.rb
  3. 3
    0
      app/views/settings/_repositories.rhtml
  4. 3
    0
      config/settings.yml
  5. 1
    0
      lang/bg.yml
  6. 1
    0
      lang/cs.yml
  7. 1
    0
      lang/da.yml
  8. 1
    0
      lang/de.yml
  9. 1
    0
      lang/en.yml
  10. 1
    0
      lang/es.yml
  11. 1
    0
      lang/fi.yml
  12. 1
    0
      lang/fr.yml
  13. 1
    0
      lang/he.yml
  14. 1
    0
      lang/hu.yml
  15. 1
    0
      lang/it.yml
  16. 1
    0
      lang/ja.yml
  17. 1
    0
      lang/ko.yml
  18. 1
    0
      lang/lt.yml
  19. 1
    0
      lang/nl.yml
  20. 1
    0
      lang/no.yml
  21. 1
    0
      lang/pl.yml
  22. 1
    0
      lang/pt-br.yml
  23. 1
    0
      lang/pt.yml
  24. 1
    0
      lang/ro.yml
  25. 1
    0
      lang/ru.yml
  26. 1
    0
      lang/sr.yml
  27. 1
    0
      lang/sv.yml
  28. 1
    0
      lang/th.yml
  29. 1
    0
      lang/uk.yml
  30. 1
    0
      lang/zh-tw.yml
  31. 1
    0
      lang/zh.yml

+ 18
- 1
app/models/changeset.rb Datei anzeigen

@@ -15,6 +15,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

require 'iconv'

class Changeset < ActiveRecord::Base
belongs_to :repository
has_many :changes, :dependent => :delete_all
@@ -43,7 +45,7 @@ class Changeset < ActiveRecord::Base
end
def comments=(comment)
write_attribute(:comments, comment.strip)
write_attribute(:comments, to_utf8(comment.to_s.strip))
end

def committed_on=(date)
@@ -131,4 +133,19 @@ class Changeset < ActiveRecord::Base
def next
@next ||= Changeset.find(:first, :conditions => ['id > ? AND repository_id = ?', self.id, self.repository_id], :order => 'id ASC')
end
private
def 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'
begin
return Iconv.conv('UTF-8', encoding, str)
rescue Iconv::Failure
# do nothing here
end
end
str
end
end

+ 39
- 0
app/models/setting.rb Datei anzeigen

@@ -33,6 +33,45 @@ class Setting < ActiveRecord::Base
'%H:%M',
'%I:%M %p'
]
ENCODINGS = %w(US-ASCII
windows-1250
windows-1251
windows-1252
windows-1253
windows-1254
windows-1255
windows-1256
windows-1257
windows-1258
windows-31j
ISO-2022-JP
ISO-2022-KR
ISO-8859-1
ISO-8859-2
ISO-8859-3
ISO-8859-4
ISO-8859-5
ISO-8859-6
ISO-8859-7
ISO-8859-8
ISO-8859-9
ISO-8859-13
ISO-8859-15
KOI8-R
UTF-8
UTF-16
UTF-16BE
UTF-16LE
EUC-JP
Shift_JIS
GB18030
GBK
ISCII91
EUC-KR
Big5
Big5-HKSCS
TIS-620)
cattr_accessor :available_settings
@@available_settings = YAML::load(File.open("#{RAILS_ROOT}/config/settings.yml"))

+ 3
- 0
app/views/settings/_repositories.rhtml Datei anzeigen

@@ -16,6 +16,9 @@

<p><label><%= l(:setting_repositories_encodings) %></label>
<%= text_field_tag 'settings[repositories_encodings]', Setting.repositories_encodings, :size => 60 %><br /><em><%= l(:text_comma_separated) %></em></p>

<p><label><%= l(:setting_commit_logs_encoding) %></label>
<%= select_tag 'settings[commit_logs_encoding]', options_for_select(Setting::ENCODINGS, Setting.commit_logs_encoding) %></p>
</div>

<fieldset class="box tabular settings"><legend><%= l(:text_issues_ref_in_commit_messages) %></legend>

+ 3
- 0
config/settings.yml Datei anzeigen

@@ -122,6 +122,9 @@ default_projects_public:
# multiple values accepted, comma separated
repositories_encodings:
default: ''
# encoding used to convert commit logs to UTF-8
commit_logs_encoding:
default: 'UTF-8'
ui_theme:
default: ''
emails_footer:

+ 1
- 0
lang/bg.yml Datei anzeigen

@@ -634,3 +634,4 @@ setting_mail_handler_api_key: API key
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/cs.yml Datei anzeigen

@@ -639,3 +639,4 @@ setting_mail_handler_api_key: API key
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/da.yml Datei anzeigen

@@ -636,3 +636,4 @@ setting_mail_handler_api_key: API key
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/de.yml Datei anzeigen

@@ -635,3 +635,4 @@ setting_mail_handler_api_key: API key
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/en.yml Datei anzeigen

@@ -209,6 +209,7 @@ setting_time_format: Time format
setting_cross_project_issue_relations: Allow cross-project issue relations
setting_issue_list_default_columns: Default columns displayed on the issue list
setting_repositories_encodings: Repositories encodings
setting_commit_logs_encoding: Commit messages encoding
setting_emails_footer: Emails footer
setting_protocol: Protocol
setting_per_page_options: Objects per page options

+ 1
- 0
lang/es.yml Datei anzeigen

@@ -637,3 +637,4 @@ setting_mail_handler_api_key: API key
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/fi.yml Datei anzeigen

@@ -634,3 +634,4 @@ setting_mail_handler_api_key: API key
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/fr.yml Datei anzeigen

@@ -210,6 +210,7 @@ setting_time_format: Format d'heure
setting_cross_project_issue_relations: Autoriser les relations entre demandes de différents projets
setting_issue_list_default_columns: Colonnes affichées par défaut sur la liste des demandes
setting_repositories_encodings: Encodages des dépôts
setting_commit_logs_encoding: Encodage des messages de commit
setting_emails_footer: Pied-de-page des emails
setting_protocol: Protocole
setting_per_page_options: Options d'objets affichés par page

+ 1
- 0
lang/he.yml Datei anzeigen

@@ -634,3 +634,4 @@ setting_mail_handler_api_key: API key
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/hu.yml Datei anzeigen

@@ -635,3 +635,4 @@ setting_mail_handler_api_key: API kulcs
text_email_delivery_not_configured: "Az E-mail küldés nincs konfigurálva, és az értesítések ki vannak kapcsolva.\nÁllítsd be az SMTP szervert a config/email.yml fájlban és indítsd újra az alkalmazást, hogy érvénybe lépjen."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/it.yml Datei anzeigen

@@ -634,3 +634,4 @@ setting_mail_handler_api_key: chiave API
text_email_delivery_not_configured: "La consegna via e-mail non è configurata e le notifiche sono disabilitate.\nConfigura il tuo server SMTP in config/email.yml e riavvia l'applicazione per abilitarle."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/ja.yml Datei anzeigen

@@ -635,3 +635,4 @@ setting_mail_handler_api_key: API key
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/ko.yml Datei anzeigen

@@ -634,3 +634,4 @@ setting_mail_handler_api_key: API key
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/lt.yml Datei anzeigen

@@ -637,3 +637,4 @@ setting_mail_handler_api_key: API raktas
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/nl.yml Datei anzeigen

@@ -635,3 +635,4 @@ setting_mail_handler_api_key: API key
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/no.yml Datei anzeigen

@@ -635,3 +635,4 @@ setting_mail_handler_api_key: API key
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/pl.yml Datei anzeigen

@@ -634,3 +634,4 @@ setting_mail_handler_api_key: API key
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/pt-br.yml Datei anzeigen

@@ -634,3 +634,4 @@ setting_mail_handler_api_key: API key
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/pt.yml Datei anzeigen

@@ -634,3 +634,4 @@ setting_mail_handler_api_key: API key
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/ro.yml Datei anzeigen

@@ -634,3 +634,4 @@ setting_mail_handler_api_key: API key
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/ru.yml Datei anzeigen

@@ -638,3 +638,4 @@ setting_mail_handler_api_key: API ключ
text_email_delivery_not_configured: "Параметры работы с почтовым сервером не настроены и функция уведомления по email не активна.\nНастроить параметры для вашего SMTP сервера вы можете в файле config/email.yml. Для применения изменений перезапустите приложение."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/sr.yml Datei anzeigen

@@ -635,3 +635,4 @@ setting_mail_handler_api_key: API key
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/sv.yml Datei anzeigen

@@ -635,3 +635,4 @@ setting_mail_handler_api_key: API key
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/th.yml Datei anzeigen

@@ -637,3 +637,4 @@ setting_mail_handler_api_key: API key
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/uk.yml Datei anzeigen

@@ -636,3 +636,4 @@ setting_mail_handler_api_key: API key
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/zh-tw.yml Datei anzeigen

@@ -635,3 +635,4 @@ enumeration_doc_categories: 文件分類
enumeration_activities: 活動 (時間追蹤)
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

+ 1
- 0
lang/zh.yml Datei anzeigen

@@ -635,3 +635,4 @@ enumeration_activities: 活动(时间跟踪)
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
field_parent_title: Parent page
label_issue_watchers: Watchers
setting_commit_logs_encoding: Commit messages encoding

Laden…
Abbrechen
Speichern