プロジェクト

全般

プロフィール

Vote #76152

完了

settings: incompatible character encodings: UTF-8 and ASCII-8BIT: yaml generated on ruby 1.8

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
高め
担当者:
-
カテゴリ:
Database_21
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
21
version_id:
91
issue_org_id:
19305
author_id:
123154
assigned_to_id:
1
comments:
9
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
89
ステータス-->[Closed]

説明

regression detected:

redmine 2.5.2 works fine, after upgrade to version 2.6.2 - can't enter to /settings,
get 500 error in browser and such record in DEBUG production.log:

ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT):
100: ) %>
101:
102:
103: <%= text_field_tag("settings[commit_update_keywords][keywords][]",
104: rule['keywords'], :size => 30) %>
105:
106:

bug cause:

this database record:

INSERT INTO `settings` VALUES (68,'commit_update_keywords','--- \n- keywords: !binary |\n    Zml4ZXMsY2xvc2VzLNC40YHQv9GA0LDQstC70LXQvdC+LNCz0L7RgtC+0LLQ\n
  vizRgdC00LXQu9Cw0L3QvixmaXhlZA==\n\n  done_ratio: \"100\"\n  status_id: \"5\"\n','2014-04-02 22:32:32');
  • this database record works fine in redmine 2.5.2 and cause 500 internal server error in redmine 2.6.2.

how to make workaround:

  1. delete from settings where name='commit_update_keywords';
    
  2. restart redmine ("systemctl restart passenger@redmine" or something like this)

  3. enter into /settings url and recreate this record manually from redmine interface,
    and now - all works fine, no more 500 errors.

after manual fix / workaround database record for commit_update_keywords now looks like this:

INSERT INTO `settings` VALUES (75,'commit_update_keywords','---\n- status_id: \'5\'\n  done_ratio: \'100\'\n  keywords: fixes,closes,исправлено,готово,сделано,fixed\n','2015-03-08 15:16:28');

P.S.

$ ruby script/about

Environment:
  Redmine version                2.6.2.stable
  Ruby version                   2.0.0-p353 (2013-11-22) [x86_64-linux]
  Rails version                  3.2.21
  Environment                    production
  Database adapter               Mysql2
SCM:
  Subversion                     1.7.14
  Git                            1.8.3.1
  Filesystem
Redmine plugins:
  redmine_agile                  1.3.8
  redmine_contacts               3.4.4
  redmine_issue_favicon          0.0.1
  redmine_people                 0.1.8

journals

--------------------------------------------------------------------------------
<pre>
$ ruby --version
ruby 1.8.7 (2014-01-28 patchlevel 376) [x86_64-linux]
$ irb
1.8.7-head :001 > require 'yaml'
=> true
1.8.7-head :002 > puts YAML.dump([{'status_id' => '0'}, {'keywords' => 'fixes,closes,исправлено,готово,сделано,fixed'}])
---
- status_id: "0"
- keywords: !binary |
Zml4ZXMsY2xvc2VzLNC40YHQv9GA0LDQstC70LXQvdC+LNCz0L7RgtC+0LLQ
vizRgdC00LXQu9Cw0L3QvixmaXhlZA==

=> nil
</pre>
--------------------------------------------------------------------------------
Toshi MARUYAMA wrote:
> ruby 1.8.7 (2014-01-28 patchlevel 376) [x86_64-linux]

Inside redmine 2.5.2 container with CentOS 6 and ruby 1.8.7
I see exactly same output, but inside redmine 2.6.2 container
with CentOS 7 I am use different version of ruby
and see different YAML.dump() results:

<pre>
$ rpm -q ruby
ruby-2.0.0.353-22.el7_0.x86_64
$ ruby --version
ruby 2.0.0p353 (2013-11-22) [x86_64-linux]
$ irb
irb(main):001:0> require 'yaml'
=> true
irb(main):002:0> puts YAML.dump([{'status_id' => '0'}, {'keywords' => 'fixes,closes,исправлено,готово,сделано,fixed'}])
---
- status_id: '0'
- keywords: fixes,closes,исправлено,готово,сделано,fixed
=> nil
</pre>

locale settings inside new 2.6.2 and old 2.5.2 redmine containers are identical:

<pre>
$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
</pre>

--------------------------------------------------------------------------------
This is very dirty workaround.
<pre><code class="diff">
diff --git a/app/models/setting.rb b/app/models/setting.rb
--- a/app/models/setting.rb
+++ b/app/models/setting.rb
@@ -96,6 +96,17 @@ class Setting < ActiveRecord::Base
# Unserialize serialized settings
v = YAML::load(v) if @@available_settings[name]['serialized'] && v.is_a?(String)
v = v.to_sym if @@available_settings[name]['format'] == 'symbol' && !v.blank?
+ if v.is_a?(String) && v.respond_to?(:force_encoding)
+ v.force_encoding('UTF-8')
+ elsif v.is_a?(Array)
+ v.each do |i|
+ if i.is_a?(Hash)
+ i.each do |k, v1|
+ v1.force_encoding('UTF-8') if v1.is_a?(String) && v1.respond_to?(:force_encoding)
+ end
+ end
+ end
+ end
v
end
</code></pre>
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,Closed,13617,Internal error on custum queries after Upgrade 2.2 -> 2.3

Admin Redmine さんが3年以上前に更新

  • カテゴリDatabase_21 にセット
  • 対象バージョン2.6.3_91 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0