プロジェクト

全般

プロフィール

Vote #65565

完了

Swedish characters get replaced with kanji signs in an issue when added via email

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
-
対象バージョン:
開始日:
2009/08/06
期日:
進捗率:

0%

予定工数:
category_id:
0
version_id:
6
issue_org_id:
3717
author_id:
1463
assigned_to_id:
0
comments:
19
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
10
ステータス-->[Closed]

説明

Swedish chars (Å,Ä and Ö) gets replaced with 奪 辰 and 旦 when added from email.

Raw sample of such an email:

MIME-Version: 1.0
From: supportform@domain.se
To: support@domain.se
Date: 23 Feb 2009 17:31:39 +0100
Subject: =?utf-8?B?w4XDhMOWIGkgYsO2cmphdCAodGVzdCBudW1tZXIgMjAp?=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: base64

U3ZlbnNrYSB0ZWNrZW4gaSBiw7ZyamFuIGF2IHN1YmplY3QNCg0KaHR0cDovL3d3dy5uZXRy
ZWxhdGlvbnMuc2Uvc3VwcG9ydC9hcmVuZGVuL25ldHJlbGF0aW9ucy8wOTAyMjMtMTczMTM5
LWFhby1pLWJvcmphdC10ZXN0LW51bW1lci0yMC8NCg0KUHJvamVjdDoga29udDUwMDENClBy
aW9yaXRldDogS3JpdGlza3Q

The really odd thing is that when I restart the application (we're using Phusion Passenger now, mongrel before, yet that doesn't seem make any difference) the problem goes away for 5 or 10 minutes, only to reappear again. Quite strange...

h2. Platform info

MySQL: 5.0.51a-3ubuntu5.4-log
Ruby: ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux]
Rails: Rails 2.3.2
Redmine version: 0.8.4.stable.2835


journals

I can confirm this also happens on my Windows box.
Database is in PostgreSQL 8.3 (UTF8 encoding).
Email messages are sent in ISO-8859-1.
Messages are fetched via IMAP.
The mail server is running Zimbra 4.5.13.

The problematic headers were :
Subject: test =?ISO-8859-1?Q?cr=E9ation_t=E2che_email?=
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Resulting task name was "test cr辿ation t但che email".
Same platform info as the original poster, appart from Win2003-R2 OS and PostgreSQL 8.3 database.
--------------------------------------------------------------------------------
Arnaud Lesauvage wrote:
> I can confirm this also happens on my Windows box.

Does your problem also temporarily disappear after restarting the Ruby application?

--------------------------------------------------------------------------------
Fredrik Frodlund wrote:
> Does your problem also temporarily disappear after restarting the Ruby application?

I always have the problem, but I don't understand what you mean by restarting the ruby application.
In my setup (IIS+fastcgi) I have one ruby.exe process that manages web requests and a scheduled task that launches a ruby.exe process to fetch emails.
This scheduled task reloads the environment every time it runs (very anoying since it takes ~20 seconds of processing time).
I could stop/restart the web service to recycle the fastcgi ruby process but that wouldn't change anything, right ?
--------------------------------------------------------------------------------
Arnaud Lesauvage wrote:
> Fredrik Frodlund wrote:
> > Does your problem also temporarily disappear after restarting the Ruby application?
>
> I always have the problem, but I don't understand what you mean by restarting the ruby application.
> In my setup (IIS+fastcgi) I have one ruby.exe process that manages web requests and a scheduled task that launches a ruby.exe process to fetch emails.
> This scheduled task reloads the environment every time it runs (very anoying since it takes ~20 seconds of processing time).
> I could stop/restart the web service to recycle the fastcgi ruby process but that wouldn't change anything, right ?

I guess since you have a differing platform, that does not apply here... Nevermind. :)
--------------------------------------------------------------------------------
I just reinstalled everything on Archlinux.
Redmine is from trunk, revision 2847. Mongrel
Exact same problem.

I stopped/restarted mongrel to see whether it helped, but it doesn't.
--------------------------------------------------------------------------------
Same problem here. German umlauts (Ä, Ö, Ü) are turned into kanji signs.
Redmine runs on a linux box here. Everything is UTF-8. Only the the mail's *subject* is inserted with wrong encoding/characters. Everything works fine with message body.
--------------------------------------------------------------------------------
I just ran into a weird thing. I tried sending a mail with just "åäö ÅÄÖ" in the subject and as expected, the characters got converted to kanji. However, I tried adding spaces between each character, like this: "å ä ö Å Ä Ö" and the characters were left intact!

I sure hope this might be a clue as to why it happens.
--------------------------------------------------------------------------------
I also tested something.
Try to put "Ä öl, häuser, für" as subject. No character will be converted into strange signs. It will suffice to put an ÄÖÅ (whatever) as first character of the subject and the rest of the subject will be fine.

Perhaps this is another hint.
--------------------------------------------------------------------------------
I just noted that mails sent in other encodings than UTF8 will also get the "kanji"-treatment. I can also confirm André's test.
--------------------------------------------------------------------------------
Fredrik Frodlund wrote:
> I just noted that mails sent in other encodings than UTF8 will also get the "kanji"-treatment. I can also confirm André's test.

Indeed, see "my comment":http://www.redmine.org/issues/3717#note-1 , encoding was ISO-8859-1.
--------------------------------------------------------------------------------
It got broken in #2059 ("see patch":http://www.redmine.org/projects/redmine/repository/revisions/1990/diff/trunk/app/models/mail_handler.rb)

The culprit: /app/models/mail_handler.rb:123

<pre>
issue.subject = email.subject.chomp.toutf8
</pre>

TMail#subject handles my case correctly (subject in iso-8859-1, with Spanish characters), and I suspect most other cases (as it should).

I don't know any Japanese, so all I can do is ask someone who does to verify this:

<pre>
TMail::Unquoter.unquote_and_convert_to("=?ISO-8859-1?Q?Nueva_modificaci=F3n?=", "utf-8")
# => "Nueva modificación" (this is correct)
TMail::Unquoter.unquote_and_convert_to("=?iso-2022-jp?B?GyRCJCIkJCQmJCgkKhsoQg==?=", "utf-8")
# => "あいうえお" (this seems OK to me, but I'm no Japanese)
</pre>

If the result is incorrect, it should be fixed (or monkey patched) in TMail::Unquoter, so as not to break other encodings.

Please notice you may need to require tmail or something.

But I believe that is indeed correct, so the problem may be elsewhere (don't know where though).

-- nachokb
--------------------------------------------------------------------------------
Now that we know what the culprit is, shouldn't we be able to resolve this. I'm just getting a little tired of fixing issues via directly in the database, is all. :)
--------------------------------------------------------------------------------
Fredrik Frodlund wrote:
> Now that we know what the culprit is, shouldn't we be able to resolve this. I'm just getting a little tired of fixing issues via directly in the database, is all. :)

Jean Philippe fixed it in a branch: http://www.redmine.org/projects/redmine/repository/revisions/2620/diff/sandbox/rails-2.3/app/models/mail_handler.rb (though I don't know if it will get to a release soon)...

-- nachokb
--------------------------------------------------------------------------------
The code is looking a bit different in r2924. I would like at least to make a local change to make the problem go away. Anyone that can help me with this?

/app/models/mail_handler.rb:124
<pre>
issue.subject = issue.subject.toutf8 if issue.subject.respond_to?(:toutf8)
</pre>

--------------------------------------------------------------------------------
Fredrik Frodlund wrote:
> The code is looking a bit different in r2924. I would like at least to make a local change to make the problem go away. Anyone that can help me with this?
>
> /app/models/mail_handler.rb:124
> [...]

Just comment that line out...

-- nachokb
--------------------------------------------------------------------------------
Wow, it really was that simple. Thanks! :)
--------------------------------------------------------------------------------
Fix committed in r3247.
--------------------------------------------------------------------------------
Merged in 0.9-stable in r3248.
--------------------------------------------------------------------------------
Jean-Philippe Lang wrote:
> Fix committed in r3247.

Thanks!
--------------------------------------------------------------------------------


related_issues

duplicates,Closed,2838,Swedish chars get mangled in issue when added via email
duplicates,Closed,3791,Subject enconding problem while email retrieving

Admin Redmine さんが約4年前に更新

  • 対象バージョン0.9.0_6 にセット

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

いいね!0
いいね!0