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

[BUG]: Strings starting with emojis cause additional whitespace in encoding #15

Open
tomaskukk opened this issue Jun 10, 2024 · 0 comments · May be fixed by #16
Open

[BUG]: Strings starting with emojis cause additional whitespace in encoding #15

tomaskukk opened this issue Jun 10, 2024 · 0 comments · May be fixed by #16

Comments

@tomaskukk
Copy link

String that starts with an emoji, and is followed with enough characters, leads to additional whitespace being added.

Looking at the code, the issue seems to be around maxNumCharsPerEncodedWord. If that limit is hit and the token starts with an emoji, an additional whitespace is added.

Also, it doesn't seem to matter where the special "token" is in the string, it will yield the same result.

Example one (working normally):

const text = "🏆 Hello!"

const encoded = rfc2047.encode(text)
const decoded = rfc2047.decode(encoded) // '🏆 Hello!'

Example two (additional whitespace added):

const text = "🏆🏆🏆🏆🏆 Hello!"

const encoded = rfc2047.encode(text)
const decoded = rfc2047.decode(encoded) // '🏆🏆🏆🏆🏆  Hello!'

Example three (additional whitespace added):

const text = "🏆1234567 Hello!"

const encoded = rfc2047.encode(text)
const decoded = rfc2047.decode(encoded) // '🏆1234567  Hello!'
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 a pull request may close this issue.

1 participant