You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2023/04/12 20:58:00 UTC

[jira] [Comment Edited] (IO-780) ReaderInputStream discards some encoding errors

    [ https://issues.apache.org/jira/browse/IO-780?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17711560#comment-17711560 ] 

Gary D. Gregory edited comment on IO-780 at 4/12/23 8:57 PM:
-------------------------------------------------------------

That's not what I see, when I step through the code:

lastCoderResult = charsetEncoder.encode(encoderIn, encoderOut, endOfInput);

returns UNDERFLOW


was (Author: garydgregory):
That's not what I see, when I step through the code:

 
{color:#66e1f8}lastCoderResult{color}{color:#d9e8f7} {color}{color:#e6e6fa}={color}{color:#d9e8f7} {color}{color:#66e1f8}charsetEncoder{color}{color:#e6e6fa}.{color}{color:#a7ec21}encode{color}{color:#f9faf4}({color}{color:#66e1f8}encoderIn{color}{color:#e6e6fa},{color}{color:#d9e8f7} {color}{color:#66e1f8}encoderOut{color}{color:#e6e6fa},{color}{color:#d9e8f7} {color}{color:#66e1f8}endOfInput{color}{color:#f9faf4}){color}{color:#e6e6fa};{color}

returns UNDERFLOW

> ReaderInputStream discards some encoding errors
> -----------------------------------------------
>
>                 Key: IO-780
>                 URL: https://issues.apache.org/jira/browse/IO-780
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Streams/Writers
>    Affects Versions: 2.11.0
>            Reporter: Marcono1234
>            Priority: Major
>
> h3. Description
> {{org.apache.commons.io.input.ReaderInputStream}} discards encoder errors in some cases instead of properly rethrowing them.
> The underlying issue is that {{lastCoderResult}} is re-assigned before it has been checked for errors and overflow ([link to code|https://github.com/apache/commons-io/blob/b9e4f5e6e718ec8e4156e31bef733874700d7cbf/src/main/java/org/apache/commons/io/input/ReaderInputStream.java#L267]).
> This was originally mentioned in pull request [#293|https://github.com/apache/commons-io/pull/293].
> h3. Example
> The {{read()}} call in the following example should throw an exception, but currently it erroneously returns -1.
> {code}
> // Encoder which throws on malformed or unmappable input
> CharsetEncoder encoder = StandardCharsets.UTF_8.newEncoder();
> ReaderInputStream in = new ReaderInputStream(new StringReader("\uD800"), encoder);
> // BUG: This should have thrown an exception because the input is malformed
> System.out.println("Read: " + in.read());
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)