-
Notifications
You must be signed in to change notification settings - Fork 51
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
Fix Sidekiq delivery method for non-UTF8 email #43
Conversation
Fix Sidekiq delivery method for non-UTF8 email
@tpitale Could you do another release? We want to get this in a GitLab patch release. |
Woah. You just created a PR, and merged it yourself without any look from me? And you added a new gem dependency to do it? |
@tpitale :/ Sorry about that, I didn't really think about it. I thought it'd be okay as it's a bug we've encountered with Sidekiq/JSON/text encoding in GitLab a few times already, where we use the same fix. I thought part of the reason why I was added as a collaborator was to be able to quickly merge minor (in my eyes) stuff like this, but I realize we never discussed that. I'm happy to revert it and discuss it properly. |
It's okay, I'm going to release this gem. But, I'd like to discuss ways we can get rid of the dependency. I think there are some simple things we can do in ruby to check for compatible encoding changes and try to encode them. If they can't be switched between encodings … we can decide what to do then. We also probably have this issue with essentially every other delivery method. |
Released 0.5.2. |
So, one issue I see is that charlock_holmes is a C extension. Not that we explicitly support jruby, but I like to imagine we do 😄 |
I'm not so sure, what we need to do is detect the encoding based on the content, and that's exactly what
We have the issue with Sidekiq, because we're encoding the message body as JSON, which requires UTF-8. If the message body isn't UTF-8 but ASCII-8BIT, JSON will error out. :( Other delivery methods don't do JSON encoding, so probably don't have this issue, right?
Fair enough. :) |
Old but relevant: http://graysoftinc.com/character-encodings/ruby-19s-string |
Also, the new |
@tpitale Right you are :/ I jumped the gun on merging this, my bad. |
Can you open an issue, with some of the email encoding that was causing issues for gitlab users? I'd like to take a stab at running it through mail_room and fixing the issue with just ruby. If it turns out it can't be done, we'll expand our use of charlock (or something else maybe). |
@DouweM in the future, I'd love to at least have a chance to 👍 any PRs before merging. I'll try to be responsive. I do appreciate all your help with this, and I'm excited that it's helping gitlab. |
A reproduction of the specific case GitLab users were having trouble with is this: message = "é"
message.force_encoding("ASCII-8BIT") Note that in this case, the message was actually UTF-8-encoded, but for some reason Ruby thought it was ASCII-8BIT, and when trying to do Reproduce this by doing: JSON.generate(message) # => error In this case, simply doing message = "é".encode('ISO-8859-1')
message.force_encoding('ASCII-8BIT')
message.force_encoding("UTF-8")
JSON.generate(message) # => error |
Thanks, I'm going to make this an issue. |
@tpitale I completely understand, and I will do better at that in the future. I thought this MR was minor, but as we see now, it definitely wasn't. |
No worries. Every OSS project is different, too. I appreciate you being considerate and working with me on this. |
I've opened issue #44 and I'll try to see if I can fix this in ruby for |
Thanks @tpitale |
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/2698.