Skip to content

decodeWithCharset doesn't flush #2664

@rossabaker

Description

@rossabaker

In fs2-3.1.3, this test fails:

    // Found by scalacheck in old http4s implementation
    test("handle overflow") {
      if (isJVM) { // Charset not supported by Scala.js
        val cs = Charset.forName("x-ISCII91")
        val s = Stream(-36.toByte)
          .covary[Fallible]
          .through(decodeWithCharset(cs))
          .compile
          .string
        assertEquals(s, Right(""))
      }
    }

The output buffer is sized to one character based on chunk length and average size queried from the decoder, but the byte expands to two characters. We need to check the CoderResult for an overflow. [edit: misdiagnosis]

This is one of the rare character sets that needs to be flushed after the final input. You can find more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions