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

Underscore (ASCII 95) should be encoded to maintain reversibility #4

Open
swhiteman opened this issue Feb 8, 2022 · 1 comment
Open

Comments

@swhiteman
Copy link

It appears that a literal underscore (ASCII 95) _ is left as-is, meaning that a space (ASCII 32) and underscore are indistinguishable in the Q-encoded result.

Example:

var q = require("q-encoding")
var utf8 = require('utf8');
q.encode(utf8.encode("❤️ Hello _it's _me"));

Expected result:

"=E2=9D=A4=EF=B8=8F_Hello_=5Fit=27s_=5Fme"

Observed result:

"=E2=9D=A4=EF=B8=8F_Hello__it=27s__me"

Further example:

utf8.decode(q.decode(
  q.encode(utf8.encode("❤️ Hello _it's _me"))
));

Result:

"❤️ Hello  it's  me"

RFC 2047 4.2(3) notes

(3) 8-bit values which correspond to printable ASCII characters other
than "=", "?", and "_" (underscore), MAY be represented as those
characters.

So _ is a special purpose character in the encoding (representing a space), so a literal _ needs to be encoded as if it were non-ASCII.

@swhiteman
Copy link
Author

@mathiasbynens any chance of pulling my PR soon?

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

No branches or pull requests

1 participant