Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1310)

Unified Diff: third_party/WebKit/Source/wtf/text/TextCodecICU.cpp

Issue 2235453002: Text Encoding: Fix "stop on error" for ICU-based codecs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-fatal-single-byte-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/text/TextCodecICU.cpp
diff --git a/third_party/WebKit/Source/wtf/text/TextCodecICU.cpp b/third_party/WebKit/Source/wtf/text/TextCodecICU.cpp
index b2c4d3f58a17c8be4cd1af6af838618de3809e26..4adf5eacbee7aced8cdeb99b16ecc04e4370d2fa 100644
--- a/third_party/WebKit/Source/wtf/text/TextCodecICU.cpp
+++ b/third_party/WebKit/Source/wtf/text/TextCodecICU.cpp
@@ -311,25 +311,22 @@ public:
: m_converter(converter)
, m_shouldStopOnEncodingErrors(stopOnError)
{
- if (m_shouldStopOnEncodingErrors) {
- UErrorCode err = U_ZERO_ERROR;
- ucnv_setToUCallBack(m_converter, UCNV_TO_U_CALLBACK_SUBSTITUTE,
- UCNV_SUB_STOP_ON_ILLEGAL, &m_savedAction,
- &m_savedContext, &err);
- ASSERT(err == U_ZERO_ERROR);
- }
+ UErrorCode err = U_ZERO_ERROR;
+ if (m_shouldStopOnEncodingErrors)
+ ucnv_setToUCallBack(m_converter, UCNV_TO_U_CALLBACK_STOP, 0, &m_savedAction, &m_savedContext, &err);
+ else
+ ucnv_setToUCallBack(m_converter, UCNV_TO_U_CALLBACK_SUBSTITUTE, 0, &m_savedAction, &m_savedContext, &err);
jsbell 2016/08/09 22:27:24 Maybe we only want the `if (m_shouldStopOnEncoding
jungshik at Google 2016/08/12 07:20:41 Indeed, confusing. https://cs.chromium.org/chrom
+ DCHECK_EQ(err, U_ZERO_ERROR);
}
~ErrorCallbackSetter()
{
- if (m_shouldStopOnEncodingErrors) {
- UErrorCode err = U_ZERO_ERROR;
- const void* oldContext;
- UConverterToUCallback oldAction;
- ucnv_setToUCallBack(m_converter, m_savedAction, m_savedContext, &oldAction, &oldContext, &err);
- ASSERT(oldAction == UCNV_TO_U_CALLBACK_SUBSTITUTE);
- ASSERT(!strcmp(static_cast<const char*>(oldContext), UCNV_SUB_STOP_ON_ILLEGAL));
- ASSERT(err == U_ZERO_ERROR);
- }
+ UErrorCode err = U_ZERO_ERROR;
+ const void* oldContext;
+ UConverterToUCallback oldAction;
+ ucnv_setToUCallBack(m_converter, m_savedAction, m_savedContext, &oldAction, &oldContext, &err);
+ DCHECK_EQ(oldAction, m_shouldStopOnEncodingErrors ? UCNV_TO_U_CALLBACK_STOP : UCNV_TO_U_CALLBACK_SUBSTITUTE);
+ DCHECK(!oldContext);
+ DCHECK_EQ(err, U_ZERO_ERROR);
}
private:
« no previous file with comments | « third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-fatal-single-byte-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698