Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

UTF-8 encoding broken due to last byte of a multi-byte character always null #35

Closed
moll opened this issue Mar 24, 2020 · 2 comments
Closed

Comments

@moll
Copy link

moll commented Mar 24, 2020

Hey,

Thanks for maintaining these ASN.1 libs! If I'm not mistaken, the UTF-8 encoding implementation in https://hackage.haskell.org/package/asn1-types-0.3.3/docs/src/Data.ASN1.Types.String.html#local-6989586621679034993 is broken due to the last byte always being set null — 0xc0 & 0x3f = 0. I presume you meant to bitwise-or it with 0x80 instead to have the first two bits be 10.

It's easy to reproduce with my surname: asn1CharacterToString ("Möll" :: ASN1CharacterString)

Just "M*** Exception: continuation bytes invalid
CallStack (from HasCallStack):
  error, called at ./Data/ASN1/Types/String.hs:109:34 in asn1-types-0.3.3-681f1a1bec95ecc832958e8497db7f3872872f9a24538c763fb4706942450148:Data.ASN1.Types.String

Cheers

@vincenthz
Copy link
Owner

thanks @moll !

@moll
Copy link
Author

moll commented Mar 25, 2020

Thank you, too!

schmittlauch added a commit to schmittlauch/nixpkgs that referenced this issue Apr 22, 2020
backports the fix for vincenthz/hs-asn1#35

(cherry picked from commit cb0e381)
stigok pushed a commit to stigok/nixpkgs that referenced this issue Jun 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants