Skip to content

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

@tomaskukk

Description

@tomaskukk

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!'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions