You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unit test Distribution.Utils.ShortText BinaryId fails #4644
FFFE and FFFF are not unassigned in the usual sense, but guaranteed not to be a Unicode character at all. They can be used to guess a text's encoding scheme, since any text containing these is by definition not a correctly encoded Unicode text. Unicode's U+FEFF Byte order mark character can be inserted at the beginning of a Unicode text to signal its endianness: a program reading such a text and encountering 0xFFFE would then know that it should switch the byte order for all the following characters.
After some investigation, the issue is in fact for the String-backed legacy fallback, whose Binary instance relies on the roundtrip property of Distribution.Utils.String.{encode,decode}StringUtf8, which fails for the BOM:
I'm confident this one's been fixed via #4928; I ran unit-tests -p BinaryId --quickcheck-tests 999999 compiled for GHC 7.6.3 a few times; and also tried the replay value; everything passed so far.
Reacted by Mikhail Glushenkov, Francesco Gazzetta and tom-bop
Activity
ezyang commentedon Jul 29, 2017
CC @hvr who introduced this test in 993d20a
fgaz commentedon Jul 29, 2017
Wikipedia says
\65534is U+FFFE <noncharacter-FFFE> not a character.Whoa.
hvr commentedon Jul 30, 2017
I need to look into why a BOM (which btw makes no sense whatsoever for UTF8 encodings) doesn't round-trip properly. Iirc I specifically tested such corner-cases in the implementation of http://hackage.haskell.org/package/text-short
PS: I just noticed this is with the GHC 7.6.3 configuration, so this may be a problem with the legacy fallback...
hvr commentedon Jul 30, 2017
After some investigation, the issue is in fact for the
String-backed legacy fallback, whoseBinaryinstance relies on the roundtrip property ofDistribution.Utils.String.{encode,decode}StringUtf8, which fails for the BOM:because
decodeStringUtf8(imho rightfully) considers a BOM invalid in an UTF8 stream, and maps it to the replacement-character.hvr commentedon Dec 3, 2017
I'll take a stab at harmonizing the
decodeStringUtf8semantics with the more round-tripping friendly ones fromtextandtext-short.Modify replacement properties of `encodeStringUtf8`/`decodeStringUtf8`
hvr commentedon Dec 4, 2017
I'm confident this one's been fixed via #4928; I ran
unit-tests -p BinaryId --quickcheck-tests 999999compiled for GHC 7.6.3 a few times; and also tried the replay value; everything passed so far.