desktop/source/app/appinit.cxx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
New commits: commit 7d37241dcb7aa20adfa7510323cfd7984ff5e911 Author: Stephan Bergmann <stephan.bergm...@allotropia.de> AuthorDate: Fri Aug 23 14:09:41 2024 +0200 Commit: Stephan Bergmann <stephan.bergm...@allotropia.de> CommitDate: Fri Aug 23 22:06:21 2024 +0200 Emscripten: Module.uno_scripts are relative to document.baseURI ...so explicitly make them absolute, in case the WorkerGlboalScope used in runUnoScriptUrl would make them absolute relative to a different base URL. (See <https://github.com/mdn/content/issues/35568> "WorkerGlobalScope.importScripts URLs relative to what base URL?" for my confusion of what base URL should actually be used there. But at least with an emsdk that uses recent Emscripten trunk towards 3.1.65, and where meanwhile worker threads no longer load an soffice.worker.js but instead use some blob: URL, a > Module.uno_scripts = ['example.js']; now failed with > Error: Failed to execute 'importScripts' on 'WorkerGlobalScope': The URL 'example.js' is invalid. on Chrome 127.) Change-Id: I9f9b43d501a7b5d933c8506debdebe67ff1b5795 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172325 Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de> Tested-by: Jenkins diff --git a/desktop/source/app/appinit.cxx b/desktop/source/app/appinit.cxx index 6253b7afe20b..1dc962e7a008 100644 --- a/desktop/source/app/appinit.cxx +++ b/desktop/source/app/appinit.cxx @@ -36,6 +36,7 @@ #include <officecfg/Setup.hxx> #include <osl/file.hxx> #include <rtl/bootstrap.hxx> +#include <rtl/uri.hxx> #include <sal/log.hxx> #include <comphelper/diagnose_ex.hxx> @@ -63,13 +64,14 @@ using namespace ::com::sun::star::ucb; namespace { -extern "C" void getUnoScriptUrls(std::vector<std::u16string> * urls) { +extern "C" void getUnoScriptUrls(std::vector<OUString> * urls) { assert(urls != nullptr); + OUString const base(emscripten::val::global("document")["baseURI"].as<std::u16string>()); auto const val = emscripten::val::module_property("uno_scripts"); if (!val.isUndefined()) { auto const len = val["length"].as<std::uint32_t>(); for (std::uint32_t i = 0; i != len; ++i) { - urls->push_back(val[i].as<std::u16string>()); + urls->push_back(rtl::Uri::convertRelToAbs(base, OUString(val[i].as<std::u16string>()))); } } } @@ -108,13 +110,13 @@ extern "C" void resolveUnoMain() { void initUno() { init_unoembind_uno(); - std::vector<std::u16string> urls; + std::vector<OUString> urls; emscripten_sync_run_in_main_runtime_thread(EM_FUNC_SIG_VI, getUnoScriptUrls, &urls); for (auto const & url: urls) { - if (url.find(' + if (url.indexOf(' throw std::invalid_argument("Module.uno_scripts element contains embedded NUL"); } - runUnoScriptUrl(url.c_str()); + runUnoScriptUrl(url.getStr()); } setupMainChannel(); EM_ASM(Module.uno_init$resolve(););