Skip to content

Avoid UnicodeDecodeError for non-utf8 QueryEvents #465

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

Merged

Conversation

oseemann
Copy link
Contributor

@oseemann oseemann commented Sep 1, 2023

Query strings in QueryEvents that appear in the binlog stream must not necessarily be utf-8 encoded, but the current implementation handles only utf-8.

This commit adds the errors="backslashreplace" kwarg to decode(), to avoid a runtime error and insert \xNN escape sequences for byte sequences that are not valid utf-8. It includes a test that generates a QueryEvent with latin-1 encoding, which fails without the fix.

Query strings in QueryEvents that appear in the binlog stream must not
necessarily be utf-8 encoded, but the current implementation handles
only utf-8.

This commit adds the `errors="backslashreplace"` kwarg to decode(), to
avoid a runtime error and insert \xNN escape sequences for byte
sequences that are not valid utf-8. It includes a test that generates a
QueryEvent with latin-1 encoding, which fails without the fix.
@julien-duponchelle
Copy link
Owner

That's awesome

@julien-duponchelle julien-duponchelle merged commit c2364bb into julien-duponchelle:main Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants