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

dev/mail#36 - Fix invalid unicode characters in bounce processing #13396

Merged
merged 3 commits into from
Jan 4, 2019

Conversation

tschuettler
Copy link
Contributor

Overview

MySQL does not accept invalid unicode characters and therefore fails to write the bounce to the database if it is part of the bounce reason.
Issue tracker: https://lab.civicrm.org/dev/mail/issues/36

Before

Exception is thrown. Bounce is not stored in the datebase, but mail is moved to processed folder.

After

Invalid character are replaced with unicode replacement character. No exception. Bounce is saved.

Technical Details

Generating an invalid unicode character was not easy. Had to use a hex editor and replaced a valid character with an invalid one.

@civibot civibot bot added the master label Jan 4, 2019
@civibot
Copy link

civibot bot commented Jan 4, 2019

(Standard links)

Final-Recipient: rfc822;my@example.com
Action: failed
Status: 5.0.0
Diagnostic-Code: X-Notes; Benutzer my (my@example.com) nicht im Domino-Verzeichnis aufgef�hrt
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The invalid character is a \x81 in aufgefhrt between f and h.

@tschuettler
Copy link
Contributor Author

Hmm, it looks like the unit tests inside that file never ran.

@eileenmcnaughton I guess this is due to class and file naming vs. the actual file path?

@eileenmcnaughton
Copy link
Contributor

@tschuettler good spotting - change looks good too

@eileenmcnaughton eileenmcnaughton merged commit 313a421 into civicrm:master Jan 4, 2019
@tschuettler
Copy link
Contributor Author

@eileenmcnaughton Thanks for merging! :)

What do you think about replacing replacing non-utf8-mysql characters like emojis aswell? They will lead to the same error until we make the switch to utf8mb4.

I looked for other cases where the unit tests name did not match and created an issue for it: https://lab.civicrm.org/dev/core/issues/647

@eileenmcnaughton
Copy link
Contributor

@tschuettler I guess in this case (saving bounce reason) the data is relatively unimportant compared to the fact it's saved - ie. we are not putting this in outgoing messages but a technical field in the db - so if there is a chance other characters could break it it would be good to handle them

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

Successfully merging this pull request may close these issues.

2 participants