From: Dmitry Volyntsev Date: Wed, 3 Jun 2026 02:00:28 +0000 (-0700) Subject: QuickJS: fixed common receiver exception classes X-Git-Tag: 1.0.0~31 X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/stylesheets/stylesheet.css?a=commitdiff_plain;h=77ca08acd534b282e034ff0d4a7b236d7a76ee9f;p=njs.git QuickJS: fixed common receiver exception classes Wrong receiver errors are caused by JS API misuse, not by internal host failures. Report TypeError for TextEncoder, TextDecoder, console, and fs Stats receiver checks. --- diff --git a/external/qjs_fs_module.c b/external/qjs_fs_module.c index 89c5281c..b9f8a360 100644 --- a/external/qjs_fs_module.c +++ b/external/qjs_fs_module.c @@ -2399,7 +2399,7 @@ qjs_fs_stats_get_own_property(JSContext *cx, JSPropertyDescriptor *pdesc, st = JS_GetOpaque2(cx, obj, QJS_CORE_CLASS_ID_FS_STATS); if (st == NULL) { - (void) JS_ThrowInternalError(cx, "\"this\" is not a Stats object"); + (void) JS_ThrowTypeError(cx, "\"this\" is not a Stats object"); return -1; } diff --git a/nginx/ngx_js.c b/nginx/ngx_js.c index e96a209e..59f48436 100644 --- a/nginx/ngx_js.c +++ b/nginx/ngx_js.c @@ -1939,7 +1939,7 @@ ngx_qjs_ext_console_time(JSContext *cx, JSValueConst this_val, int argc, console = JS_GetOpaque(this_val, NGX_QJS_CLASS_ID_CONSOLE); if (console == NULL) { - return JS_ThrowInternalError(cx, "this is not a console object"); + return JS_ThrowTypeError(cx, "this is not a console object"); } if (console == (void *) 1) { @@ -2026,7 +2026,7 @@ ngx_qjs_ext_console_time_end(JSContext *cx, JSValueConst this_val, int argc, console = JS_GetOpaque(this_val, NGX_QJS_CLASS_ID_CONSOLE); if (console == NULL) { - return JS_ThrowInternalError(cx, "this is not a console object"); + return JS_ThrowTypeError(cx, "this is not a console object"); } if (!JS_IsUndefined(argv[0])) { diff --git a/src/qjs.c b/src/qjs.c index 3c75bb9d..c6c05586 100644 --- a/src/qjs.c +++ b/src/qjs.c @@ -742,7 +742,7 @@ qjs_text_decoder_decode(JSContext *cx, JSValueConst this_val, int argc, td = JS_GetOpaque(this_val, QJS_CORE_CLASS_ID_TEXT_DECODER); if (td == NULL) { - return JS_ThrowInternalError(cx, "'this' is not a TextDecoder"); + return JS_ThrowTypeError(cx, "'this' is not a TextDecoder"); } ret = qjs_typed_array_data(cx, argv[0], &data); @@ -802,7 +802,7 @@ qjs_text_decoder_encoding(JSContext *ctx, JSValueConst this_val) td = JS_GetOpaque(this_val, QJS_CORE_CLASS_ID_TEXT_DECODER); if (td == NULL) { - return JS_ThrowInternalError(ctx, "'this' is not a TextDecoder"); + return JS_ThrowTypeError(ctx, "'this' is not a TextDecoder"); } switch (td->encoding) { @@ -821,7 +821,7 @@ qjs_text_decoder_fatal(JSContext *ctx, JSValueConst this_val) td = JS_GetOpaque(this_val, QJS_CORE_CLASS_ID_TEXT_DECODER); if (td == NULL) { - return JS_ThrowInternalError(ctx, "'this' is not a TextDecoder"); + return JS_ThrowTypeError(ctx, "'this' is not a TextDecoder"); } return JS_NewBool(ctx, td->fatal); @@ -835,7 +835,7 @@ qjs_text_decoder_ignore_bom(JSContext *ctx, JSValueConst this_val) td = JS_GetOpaque(this_val, QJS_CORE_CLASS_ID_TEXT_DECODER); if (td == NULL) { - return JS_ThrowInternalError(ctx, "'this' is not a TextDecoder"); + return JS_ThrowTypeError(ctx, "'this' is not a TextDecoder"); } return JS_NewBool(ctx, td->ignore_bom); @@ -915,7 +915,7 @@ qjs_text_encoder_encode(JSContext *cx, JSValueConst this_val, int argc, te = JS_GetOpaque(this_val, QJS_CORE_CLASS_ID_TEXT_ENCODER); if (te == NULL) { - return JS_ThrowInternalError(cx, "'this' is not a TextEncoder"); + return JS_ThrowTypeError(cx, "'this' is not a TextEncoder"); } if (!JS_IsString(argv[0])) { @@ -986,7 +986,7 @@ qjs_text_encoder_encode_into(JSContext *cx, JSValueConst this_val, int argc, te = JS_GetOpaque(this_val, QJS_CORE_CLASS_ID_TEXT_ENCODER); if (te == NULL) { - return JS_ThrowInternalError(cx, "'this' is not a TextEncoder"); + return JS_ThrowTypeError(cx, "'this' is not a TextEncoder"); } if (!JS_IsString(argv[0])) {