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

Do not make the encoded document larger than expected #67

Merged
merged 1 commit into from
Jul 12, 2023

Conversation

agateau-gg
Copy link
Collaborator

The Unicode replacement character becomes 2 bytes in UTF-8 (0xFF 0xFD). Replacing \0 with this character causes the encoded string to be one byte longer, making it possible for the encoded document to be longer than the maximum document size.

Use the ASCII substitute character instead: it's only 1 byte long in UTF-8, so it does not make the encoded document grow.

This is going to help with GitGuardian/ggshield#561.

The Unicode replacement character becomes 2 bytes in UTF-8 (0xFF 0xFD).
Replacing \0 with this character causes the encoded string to be one
byte longer, making it possible for the encoded document to be longer
than the maximum document size.

Use the ASCII substitute character instead: it's only 1 byte long in
UTF-8, so it does not make the encoded document grow.
@agateau-gg agateau-gg changed the title Ddo not make the encoded document larger than expected Do not make the encoded document larger than expected Jul 12, 2023
@agateau-gg agateau-gg requested a review from Walz July 12, 2023 15:51
Copy link
Collaborator

@Walz Walz left a comment

Choose a reason for hiding this comment

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

LGTM

@agateau-gg agateau-gg merged commit ccd3e47 into master Jul 12, 2023
@agateau-gg agateau-gg deleted the agateau/fix-maximum-size-check branch July 12, 2023 16:02
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