From 4bfede4187703a4ad7a115f648580d97187be74a Mon Sep 17 00:00:00 2001 From: Dominik Seifert Date: Mon, 28 Aug 2023 09:56:19 +0200 Subject: [PATCH] add dummy URLSearchParams --- src/main/cpp/bgjs/BGJSV8Engine.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/cpp/bgjs/BGJSV8Engine.cpp b/src/main/cpp/bgjs/BGJSV8Engine.cpp index 9d1bbac..508458e 100644 --- a/src/main/cpp/bgjs/BGJSV8Engine.cpp +++ b/src/main/cpp/bgjs/BGJSV8Engine.cpp @@ -1210,12 +1210,22 @@ void BGJSV8Engine::createContext() { // Create a new context. Local context = v8::Context::New(_isolate, nullptr, globalObjTpl); + + // URLSearchParams are not supported! This is just a dummy object to prevent crashes of libraries that are referencing it, but do not use it + v8::Local URLSearchParams = v8::FunctionTemplate::New(_isolate); + URLSearchParams->Set( + String::NewFromUtf8(_isolate, "youShallNotUseMe").ToLocalChecked(), + v8::FunctionTemplate::New(_isolate,LogCallback,Local(),Local(),0,ConstructorBehavior::kThrow) + ); + + context->SetAlignedPointerInEmbedderData(EBGJSV8EngineEmbedderData::kContext, this); // register global object for all required modules v8::Context::Scope ctxScope(context); context->Global()->Set(context, String::NewFromUtf8(_isolate, "global").ToLocalChecked(), context->Global()); context->Global()->Set(context, v8::String::NewFromUtf8(_isolate, "console").ToLocalChecked(), console->GetFunction(context).ToLocalChecked()); + context->Global()->Set(context, v8::String::NewFromUtf8(_isolate, "URLSearchParams").ToLocalChecked(),URLSearchParams->GetFunction(context).ToLocalChecked()); _context.Reset(_isolate, context);