From c49326e942d7cc21f78fe187020dce73befdd935 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Tue, 4 Jun 2019 22:44:55 +0300 Subject: Import WebKit commit 5ccca3a720f7c2251c4ac8b28f25bd73524081f0 Change-Id: Idfb37cd43929536d4c67d1fa5d8cb598e9c0ad7e Reviewed-by: Konstantin Tokarev --- Source/JavaScriptCore/parser/Parser.cpp | 16 ++++++++-------- Source/JavaScriptCore/parser/Parser.h | 3 +++ 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'Source/JavaScriptCore/parser') diff --git a/Source/JavaScriptCore/parser/Parser.cpp b/Source/JavaScriptCore/parser/Parser.cpp index c66b74282..f4751616f 100644 --- a/Source/JavaScriptCore/parser/Parser.cpp +++ b/Source/JavaScriptCore/parser/Parser.cpp @@ -90,7 +90,7 @@ void Parser::logError(bool) return; StringPrintStream stream; printUnexpectedTokenText(stream); - setErrorMessage(stream.toString()); + setErrorMessage(stream.toStringWithLatin1Fallback()); } template template @@ -104,7 +104,7 @@ void Parser::logError(bool shouldPrintToken, const A& value1) stream.print(". "); } stream.print(value1, "."); - setErrorMessage(stream.toString()); + setErrorMessage(stream.toStringWithLatin1Fallback()); } template template @@ -118,7 +118,7 @@ void Parser::logError(bool shouldPrintToken, const A& value1, const B stream.print(". "); } stream.print(value1, value2, "."); - setErrorMessage(stream.toString()); + setErrorMessage(stream.toStringWithLatin1Fallback()); } template template @@ -132,7 +132,7 @@ void Parser::logError(bool shouldPrintToken, const A& value1, const B stream.print(". "); } stream.print(value1, value2, value3, "."); - setErrorMessage(stream.toString()); + setErrorMessage(stream.toStringWithLatin1Fallback()); } template template @@ -146,7 +146,7 @@ void Parser::logError(bool shouldPrintToken, const A& value1, const B stream.print(". "); } stream.print(value1, value2, value3, value4, "."); - setErrorMessage(stream.toString()); + setErrorMessage(stream.toStringWithLatin1Fallback()); } template template @@ -160,7 +160,7 @@ void Parser::logError(bool shouldPrintToken, const A& value1, const B stream.print(". "); } stream.print(value1, value2, value3, value4, value5, "."); - setErrorMessage(stream.toString()); + setErrorMessage(stream.toStringWithLatin1Fallback()); } template template @@ -174,7 +174,7 @@ void Parser::logError(bool shouldPrintToken, const A& value1, const B stream.print(". "); } stream.print(value1, value2, value3, value4, value5, value6, "."); - setErrorMessage(stream.toString()); + setErrorMessage(stream.toStringWithLatin1Fallback()); } template template @@ -188,7 +188,7 @@ void Parser::logError(bool shouldPrintToken, const A& value1, const B stream.print(". "); } stream.print(value1, value2, value3, value4, value5, value6, value7, "."); - setErrorMessage(stream.toString()); + setErrorMessage(stream.toStringWithLatin1Fallback()); } template diff --git a/Source/JavaScriptCore/parser/Parser.h b/Source/JavaScriptCore/parser/Parser.h index 02a726a56..bce94ba25 100644 --- a/Source/JavaScriptCore/parser/Parser.h +++ b/Source/JavaScriptCore/parser/Parser.h @@ -1114,7 +1114,10 @@ private: void setErrorMessage(const String& message) { + ASSERT_WITH_MESSAGE(!message.isEmpty(), "Attempted to set the empty string as an error message. Likely caused by invalid UTF8 used when creating the message."); m_errorMessage = message; + if (m_errorMessage.isEmpty()) + m_errorMessage = ASCIILiteral("Unparseable script"); } NEVER_INLINE void logError(bool); -- cgit v1.2.1