Bug 1170668 - Improve short read handling in nsConverterInputStream, r=hsivonen
This patch changes how nsConverterInputStream handles passing data through to the underlying unicode converter in order to make it more reliably handle propagating errors and deal with short reads from the underlying input stream. This was done by making the code continuously read within the Fill method until at least one character has been decoded from the input stream, so that we don't spuriously communicate an EOF to the caller due to a short read not producing enough bytes for the decoder to produce a UTF-16 character. In addition, while making this change it became easier to signal to the decoder about the final read from the input stream, meaning that partial characters at the end of the stream will now generate a replacement character, rather than being ignored. Differential Revision: https://phabricator.services.mozilla.com/D152682
Showing
- intl/uconv/nsConverterInputStream.cpp 79 additions, 62 deletionsintl/uconv/nsConverterInputStream.cpp
- intl/uconv/tests/gtest/TestShortRead.cpp 106 additions, 0 deletionsintl/uconv/tests/gtest/TestShortRead.cpp
- intl/uconv/tests/gtest/moz.build 11 additions, 0 deletionsintl/uconv/tests/gtest/moz.build
- intl/uconv/tests/moz.build 4 additions, 0 deletionsintl/uconv/tests/moz.build
- intl/uconv/tests/unit/test_bug317216.js 4 additions, 4 deletionsintl/uconv/tests/unit/test_bug317216.js
- xpcom/io/nsIUnicharInputStream.idl 19 additions, 17 deletionsxpcom/io/nsIUnicharInputStream.idl
intl/uconv/tests/gtest/TestShortRead.cpp
0 → 100644
intl/uconv/tests/gtest/moz.build
0 → 100644
Please register or sign in to comment