Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Japanese encoding 7-bit iso-2022-jp is processed incorrectly #2498

Closed
lsergei opened this issue Feb 27, 2019 · 29 comments
Closed

Japanese encoding 7-bit iso-2022-jp is processed incorrectly #2498

lsergei opened this issue Feb 27, 2019 · 29 comments

Comments

@lsergei
Copy link

lsergei commented Feb 27, 2019

Infos:

  • Used Zammad version: latest version 2.9.x
  • Installation method (source, package, ..): package
  • Operating system: CentOS 7.1
  • Database + version: Postgres
  • Elasticsearch version:
  • Browser + version: All browsers
  • Ticket-ID: #1042716 (1047950, 1076276)

Expected behavior:

Normal processing of all japanese language email messages.

Actual behavior:

While processing email messages encoded with 7-bi iso-2022-jp charset, message is decoded incorrectly.

Assuming issue with mail parser.

Other encoding/charset combinations seem to be working just fine.

Steps to reproduce the behavior:

Send email to mailbox connected to Zammad queue in 7bit/iso-2022-jp

As already explained, combination of 7-bit encoding and iso-2022-jp charset in email message results in garbled text in corresponding ticket.

For example, below is plaintext of email:

--_000_SL2P216MB032969A22C6D22226A7B3613EF740SL2P216MB0329KORP_
Content-Type: text/plain; charset="iso-2022-jp"
Content-Transfer-Encoding: quoted-printable

=1B$B$3$N%"%I%l%9$X$N%a%k%^%,$r2r=3D|$7$F$/$@$5$$!#=1B(B

--_000_SL2P216MB032969A22C6D22226A7B3613EF740SL2P216MB0329KORP_
Content-Type: text/html; charset="iso-2022-jp"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-2022-=
jp">
<style type=3D"text/css" style=3D"display:none;"> P {margin-top:0;margin-bo=
ttom:0;} </style>
</head>
<body dir=3D"ltr">
<div style=3D"font-family: Meiryo, =1B$B%a%$%j%*=1B(B, &quot;Hiragino Sans&=
quot;, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
=1B$B$3$N%"%I%l%9$X$N%a%k%^%,$r2r=3D|$7$F$/$@$5$$!#=1B(B</div>
</body>
</html>

email client will show it as properly formatted HTML message:

このアドレスへのメルマガを解除してください。

This is how Zammad will show the ticket body:

$B$3$N%"%I%l%9$X$N%a%k%^%,$r2r=|$7$F$/$@$5$$!#(B
@thorsteneckel
Copy link
Contributor

Konnichiwa @lsergei - could you please provide a complete example mail that we then can use for our test suite? That would help a lot. Thanks!

@lsergei
Copy link
Author

lsergei commented Feb 27, 2019

Konnichiwa @thorsteneckel, thank you for the fast response.

How you'd like me to forward you a problematic message? Just forwarding it might (and most likely will) replace headers

@thorsteneckel
Copy link
Contributor

Usually the mail program has an option to save a raw mail to .eml format. For Apple Mail e.g. it's just File -> Save As. Please make sure to open that file in a regular text editor and remove all sensitive data before uploading it here.

@lsergei
Copy link
Author

lsergei commented Feb 27, 2019

@thorsteneckel thank you for the explanation. Please see the message enclosed.
As GitHub doesn't support uploading of eml files, file extension was changed to txt.

メルマガ解除.txt

@MrGeneration
Copy link
Member

Domo arigato!
Issue is verified, we'll update this issue as soon as we're ablet to work on it.

@thorsteneckel
Copy link
Contributor

thorsteneckel commented Jul 2, 2019

So the root cause of this issue is that the dependency we're using for parsing mails does not support ISO 2022 JP encoded mails. There is an additional gem that brings that support to older versions but is not compatible with the (latest) version we're using.
There is a 6 year old, stale and pending Pull Request on which I added a comment to ask for instructions on how to pick up from there. Waiting for feedback...

@MrGeneration
Copy link
Member

Can we please re-evaluate if there possibly is a working solution by now?

@thorsteneckel
Copy link
Contributor

There have been no relevant changes in the mail gem and my last comment is therefore (unfortunately) still valid.

@MrGeneration
Copy link
Member

Mantas, can you please have a look if there's maybe a solution to work around this without hacking over 7 year old hacked gems? Maybe a conversion would be possible before or so.

@thorsteneckel
Copy link
Contributor

Hi @lsergei - the great @mantas found a workaround for the mail gem issue so that we can handle it in our code instead. A sustainable solution in the gem itself would be much nicer but a huge task we can't accomplish right now. However, feel free to test it in the upcoming Zammad 3.4 release in about 2 weeks.

@lsergei
Copy link
Author

lsergei commented Jun 2, 2020

Hi @thorsteneckel and @mantas - thank you, appreciate your efforts! Will test and give you feedback.

Looking forward to new release

@hiromayu
Copy link

Hi. I'm new at zammad.
I think this problem is not fixed at 3.6.x
my zammad server show similar garbled characters.

@MrGeneration
Copy link
Member

@hiromayu Would it be possible to receive an original eml file of a email with above encodings that still does fail within Zammad 3.6? You can send this eml to support [at] zammad [dot] com with referencing this issue. We'll have a look then.

Thank you.

@hiromayu
Copy link

Hi MrGeneration. I send eml file to support .

@lsergei
Copy link
Author

lsergei commented Dec 29, 2020

@hiromayu @MrGeneration this problem is not fixed yet indeed. I kind of gave up (have someone to fix those emails manually)

@MrGeneration
Copy link
Member

Just as a small follow up:
Thanks to @hiromayu and the sample mail we could pin down the issue.

It's indirectly covering this issue and issue #3096

@hiromayu
Copy link

hiromayu commented Jan 7, 2021

Hello. Thank you All.
I think this problem is fixed by applying patch.
https://github.com/kuroda/mail-iso-2022-jp.
my Zammad server handle the mail that I had sent to support perfectly.

@lsergei
Copy link
Author

lsergei commented Jan 7, 2021

@hiromayu thank you for the update! May I know how you applied the patch? Just installed the gem as described in github article?

@hiromayu
Copy link

hiromayu commented Jan 7, 2021

I forgot to tell that I could not distinguish the reason that fixing this problem.
I applied patch and updated zammad server.so one of them or both fixed the problem.
I applied the patch by command.
sudo zammad run gem install mail-iso-2022-jp
and reboot.

@lsergei
Copy link
Author

lsergei commented Jan 7, 2021

Thank you @hiromayu . Just installed the gem but supposedly just install wouldn't fix the issue. May I know what did you change in server.so?

@hiromayu
Copy link

hiromayu commented Jan 7, 2021

I'm sorry. I didn't do anything to server.so. I just install that patch and update zammad server introduced by ubuntu updater.
if just installing the patch wouldn't work. it's too first to decide problem fixed. I will check my email at several day.

@lsergei
Copy link
Author

lsergei commented Jan 7, 2021

@hiromayu わかりました。I did the same thing and will monitor if the problem is gone.

どもありがとう!

@MrGeneration
Copy link
Member

Just an important side note: Keep in mind that this action is not update safe.
So if you really want to stick with the solution and bugfix #3096 is not installed on your system we can't stop you.

However, all bugs that are appearing because of this no longer validate for bug fixing.

@lsergei
Copy link
Author

lsergei commented Jan 7, 2021

@MrGeneration from what @hiromayu suggested it is actually update safe since there is no code modification.

Perhaps closing the ticket is too early, but for today I have no issues after installing said gem.

@MrGeneration
Copy link
Member

You did change the enviroment.
This being said, if you don't have a specific source code installation setup, this action is not update safe.

@thorsteneckel
Copy link
Contributor

thorsteneckel commented Jan 7, 2021

Hey there! To provide some technical background: Installing a gem has no effect on its own. It won't get loaded without further action/code changes. Therefore I'd suggest to remove the installed gem again to restore a vanilla environment. I suspect that the provided fix of #3096 created 7 days ago resolved your issue @hiromayu 🤔

@hiromayu
Copy link

hiromayu commented Jan 7, 2021

Thank you for all. So, update of Zammad was the reason that fix this problem.
I'm sorry for incorrect information.
I will reinstall Zammad server and check the result. and report it's really fixed at several days after.

@hiromayu
Copy link

Hello. I got another example of this problem.
but, I think small difference before update of zammad.
before update, all of japanese character was garbled. but now subject of mail is correct. only main text of mail is garbled.
What should I do?

@MrGeneration
Copy link
Member

Please create a new issue.
This is a complex issue and may appear to be the same but also might be of slightly different nature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants