diff --git a/ecmascript/builtins/builtins_global.cpp b/ecmascript/builtins/builtins_global.cpp index c53aa8df24..29c24146a6 100644 --- a/ecmascript/builtins/builtins_global.cpp +++ b/ecmascript/builtins/builtins_global.cpp @@ -227,7 +227,7 @@ JSTaggedValue BuiltinsGlobal::Encode(JSThread *thread, const JSHandleGetEcmaVM()->GetFactory(); @@ -257,6 +257,7 @@ JSTaggedValue BuiltinsGlobal::Encode(JSThread *thread, const JSHandle= base::utf_helper::DECODE_TRAIL_LOW && cc <= base::utf_helper::DECODE_TRAIL_HIGH) { + errorMsg = "DecodeURI: invalid character: " + ConvertToString(str.GetTaggedValue()); THROW_URI_ERROR_AND_RETURN(thread, errorMsg.c_str(), JSTaggedValue::Exception()); } @@ -274,10 +275,12 @@ JSTaggedValue BuiltinsGlobal::Encode(JSThread *thread, const JSHandle base::utf_helper::DECODE_TRAIL_HIGH) { + errorMsg = "DecodeURI: invalid character: " + ConvertToString(str.GetTaggedValue()); THROW_URI_ERROR_AND_RETURN(thread, errorMsg.c_str(), JSTaggedValue::Exception()); } vv = base::utf_helper::UTF16Decode(cc, kc); @@ -495,16 +498,18 @@ JSTaggedValue BuiltinsGlobal::DecodePercentEncoding(JSThread *thread, const JSHa judgURIFunc IsInURISet, int32_t strLen, std::u16string &sStr) { [[maybe_unused]] uint32_t start = static_cast(k); - [[maybe_unused]] CString errorMsg = "DecodeURI: invalid character: " + ConvertToString(str.GetTaggedValue()); + CString errorMsg; // ii. If k + 2 is greater than or equal to strLen, throw a URIError exception. // iii. If the code units at index (k+1) and (k + 2) within string do not represent hexadecimal digits, // throw a URIError exception. if ((k + 2) >= strLen) { // 2: means plus 2 + errorMsg = "DecodeURI: invalid character: " + ConvertToString(str.GetTaggedValue()); THROW_URI_ERROR_AND_RETURN(thread, errorMsg.c_str(), JSTaggedValue::Exception()); } uint16_t frontChar = EcmaStringAccessor(str).Get(k + 1); uint16_t behindChar = EcmaStringAccessor(str).Get(k + 2); // 2: means plus 2 if (!(IsHexDigits(frontChar) && IsHexDigits(behindChar))) { + errorMsg = "DecodeURI: invalid character: " + ConvertToString(str.GetTaggedValue()); THROW_URI_ERROR_AND_RETURN(thread, errorMsg.c_str(), JSTaggedValue::Exception()); } uint8_t bb = GetValueFromTwoHex(frontChar, behindChar); @@ -550,6 +555,7 @@ JSTaggedValue BuiltinsGlobal::DecodePercentEncoding(JSThread *thread, const JSHa } // 2. If n equals 1 or n is greater than 4, throw a URIError exception. if ((n == 1) || (n > 4)) { + errorMsg = "DecodeURI: invalid character: " + ConvertToString(str.GetTaggedValue()); THROW_URI_ERROR_AND_RETURN(thread, errorMsg.c_str(), JSTaggedValue::Exception()); } @@ -557,6 +563,7 @@ JSTaggedValue BuiltinsGlobal::DecodePercentEncoding(JSThread *thread, const JSHa // 5. If k + (3 × (n – 1)) is greater than or equal to strLen, throw a URIError exception. if (k + (3 * (n - 1)) >= strLen) { // 3: means multiply by 3 + errorMsg = "DecodeURI: invalid character: " + ConvertToString(str.GetTaggedValue()); THROW_URI_ERROR_AND_RETURN(thread, errorMsg.c_str(), JSTaggedValue::Exception()); } int32_t j = 1; @@ -567,10 +574,12 @@ JSTaggedValue BuiltinsGlobal::DecodePercentEncoding(JSThread *thread, const JSHa // c. If the code units at index (k +1) and (k + 2) within string do not represent hexadecimal // digits, throw a URIError exception. if (!(codeUnit == '%')) { + errorMsg = "DecodeURI: invalid character: " + ConvertToString(str.GetTaggedValue()); THROW_URI_ERROR_AND_RETURN(thread, errorMsg.c_str(), JSTaggedValue::Exception()); } if (!(IsHexDigits(EcmaStringAccessor(str).Get(k + 1)) && IsHexDigits(EcmaStringAccessor(str).Get(k + 2)))) { // 2: means plus 2 + errorMsg = "DecodeURI: invalid character: " + ConvertToString(str.GetTaggedValue()); THROW_URI_ERROR_AND_RETURN(thread, errorMsg.c_str(), JSTaggedValue::Exception()); } uint16_t frontChart = EcmaStringAccessor(str).Get(k + 1); @@ -578,6 +587,7 @@ JSTaggedValue BuiltinsGlobal::DecodePercentEncoding(JSThread *thread, const JSHa bb = GetValueFromTwoHex(frontChart, behindChart); // e. If the two most significant bits in B are not 10, throw a URIError exception. if (!((bb & BIT_MASK_TWO) == BIT_MASK_ONE)) { + errorMsg = "DecodeURI: invalid character: " + ConvertToString(str.GetTaggedValue()); THROW_URI_ERROR_AND_RETURN(thread, errorMsg.c_str(), JSTaggedValue::Exception()); } k += 2; // 2: means plus 2 diff --git a/ecmascript/compiler/builtins/builtins_array_stub_builder.cpp b/ecmascript/compiler/builtins/builtins_array_stub_builder.cpp index 03ee6ac8e1..d0ba20e09c 100644 --- a/ecmascript/compiler/builtins/builtins_array_stub_builder.cpp +++ b/ecmascript/compiler/builtins/builtins_array_stub_builder.cpp @@ -2222,7 +2222,7 @@ void BuiltinsArrayStubBuilder::FindIndex(GateRef glue, GateRef thisValue, GateRe GateRef retValue = JSCallDispatch(glue, callbackFnHandle, Int32(NUM_MANDATORY_JSFUNC_ARGS), 0, Circuit::NullGate(), JSCallMode::CALL_THIS_ARG3_WITH_RETURN, { argHandle, *kValue, key, thisValue }); - BRANCH(TaggedIsException(retValue), &hasException, ¬HasException); + BRANCH(HasPendingException(glue), &hasException, ¬HasException); Bind(&hasException); { result->WriteVariable(retValue); diff --git a/test/moduletest/arrayfindindex/arrayfindindex.js b/test/moduletest/arrayfindindex/arrayfindindex.js index 7a6019d726..b2bacfc7d5 100644 --- a/test/moduletest/arrayfindindex/arrayfindindex.js +++ b/test/moduletest/arrayfindindex/arrayfindindex.js @@ -36,4 +36,19 @@ } array1.__proto__.push(6); print(findIndex()) -})(); \ No newline at end of file +})(); + +{ + class C1 { + [28262n] = 28262n; + } + const v2 = new C1(); + const v3 = [-4.869758437495864e+307,1000000000000.0]; + function f4(a5, a6) { + for (const v7 in v2) { + } + a6(); + return a6; + } + try { v3.findIndex(f4);} catch (err) { print(err)}; +} \ No newline at end of file diff --git a/test/moduletest/arrayfindindex/expect_output.txt b/test/moduletest/arrayfindindex/expect_output.txt index 1e25f928f6..3302b499ea 100644 --- a/test/moduletest/arrayfindindex/expect_output.txt +++ b/test/moduletest/arrayfindindex/expect_output.txt @@ -13,3 +13,4 @@ 2 0 +TypeError: is not callable