Skip to content

Reader does not detect encoding correctly when stream buffer requires filling while in IVM #954

@popematt

Description

@popematt

Here is a minimal-ish reproduction:

#[test]
fn test_detect_encoding_from_stream() {
    let data = [
        0xE0u8, 0x01, 0x00, 0xEA, // IVM
        0x83, 65, 66, 67, // String: "ABC"
    ];

    let mut input: Box<dyn Read> = Box::new(io::empty());
    for input_byte in data {
        input = Box::new(input.chain(Cursor::new([input_byte])));
    }
    let _values: Vec<_> = Reader::new(AnyEncoding, input)
        .expect("a reader")
        .collect::<IonResult<_>>()
        .expect("values should be read successfully");
}

It fails with:

values should be read successfully: Decoding(DecodingError { description: "found unrecognized syntax\n    while reading a value\n        offset=0\n        input=[E0]\n        buffer len=1\n        ", position: Some(Position { byte_offset: 0, byte_length: Some(1), line_column: None }) })

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions