From b9fabe1b31f14dcba39fdcd7ede704ba58de187a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 17:40:55 +0000 Subject: [PATCH 1/8] Bump dompurify from 2.3.6 to 2.5.4 Bumps [dompurify](https://github.com/cure53/DOMPurify) from 2.3.6 to 2.5.4. - [Release notes](https://github.com/cure53/DOMPurify/releases) - [Commits](https://github.com/cure53/DOMPurify/compare/2.3.6...2.5.4) --- updated-dependencies: - dependency-name: dompurify dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 08ce09ef46..c0986f23c9 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "core-js": "3.38.1", "css-loader": "5.2.7", "d3": "7.8.4", - "dompurify": "2.3.6", + "dompurify": "2.5.4", "eslint": "8.57.0", "eslint-config-standard": "17.1.0", "eslint-import-resolver-webpack": "0.13.9", From e0b82c5aab4e35e9f2e09cabe2b62cfb3e63cd48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kinen?= Date: Fri, 13 Dec 2024 13:55:24 +0200 Subject: [PATCH 2/8] Bump dompurify to latest 2.5.x --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c0986f23c9..81469de0e8 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "core-js": "3.38.1", "css-loader": "5.2.7", "d3": "7.8.4", - "dompurify": "2.5.4", + "dompurify": "2.5.8", "eslint": "8.57.0", "eslint-config-standard": "17.1.0", "eslint-import-resolver-webpack": "0.13.9", From c8e971f136ca386d8ef4df6c327aa99662415dbf Mon Sep 17 00:00:00 2001 From: Pekka Helesuo Date: Thu, 12 Dec 2024 13:16:29 +0200 Subject: [PATCH 3/8] return decoded value from url cleanup function --- .../view/ServiceEndPoint/ServiceUrlInputHelper.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bundles/admin/admin-layereditor/view/ServiceEndPoint/ServiceUrlInputHelper.js b/bundles/admin/admin-layereditor/view/ServiceEndPoint/ServiceUrlInputHelper.js index f648974040..f4f06593ba 100644 --- a/bundles/admin/admin-layereditor/view/ServiceEndPoint/ServiceUrlInputHelper.js +++ b/bundles/admin/admin-layereditor/view/ServiceEndPoint/ServiceUrlInputHelper.js @@ -19,9 +19,7 @@ export const cleanUrl = (url) => { keysToDelete.forEach((key) => urlObj.searchParams.delete(key)); const parts = urlObj.toString().split('://'); - if (parts.length > 1) { - return parts[1]; - } - - return urlObj.toString(); + const retValString = parts.length > 1 ? parts[1] : urlObj.toString(); + const decoded = decodeURIComponent(retValString); + return decoded; }; From 46bf6f3b551a528b791bd7aa66faa31161f10116 Mon Sep 17 00:00:00 2001 From: Pekka Helesuo Date: Thu, 12 Dec 2024 13:28:22 +0200 Subject: [PATCH 4/8] add unit tests --- .../view/ServiceEndPoint/ServiceUrlInputHelper.test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bundles/admin/admin-layereditor/view/ServiceEndPoint/ServiceUrlInputHelper.test.js b/bundles/admin/admin-layereditor/view/ServiceEndPoint/ServiceUrlInputHelper.test.js index 885e0ff91d..e9684d8a4f 100644 --- a/bundles/admin/admin-layereditor/view/ServiceEndPoint/ServiceUrlInputHelper.test.js +++ b/bundles/admin/admin-layereditor/view/ServiceEndPoint/ServiceUrlInputHelper.test.js @@ -59,5 +59,13 @@ describe('ServiceUrlInputHelper Tests ', () => { const url = 'www.com/'; expect(cleanUrl(url)).toBe(url); }); + + it('should NOT encode URL params', () => { + const url = 'avoin-karttakuva.maanmittauslaitos.fi/kiinteisto-avoin/tiles/wmts/1.0.0/kiinteistojaotus/default/v3/ETRS-TM35FIN/{z}/{y}/{x}.pbf'; + expect(cleanUrl(url)).toBe(url); + + const url2 = 'www.com/?first=1&SECOND=2&thiRd=3'; + expect(cleanUrl(url2)).toBe(url2); + }); }); }); From c300f856d1de3c8205444e0c56b5946a706433e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tuomas=20Riihim=C3=A4ki?= Date: Wed, 11 Dec 2024 01:29:42 +0200 Subject: [PATCH 5/8] Remove cesium hacks, and add webpack-import-meta-loader to webpack/config.js --- package.json | 6 +- webpack/config.js | 4 + webpack/hacks/cesium/README.md | 25 --- .../hacks/cesium/buildModuleUrl.js.modified | 158 ------------------ webpack/hacks/postinstall.js | 19 --- 5 files changed, 7 insertions(+), 205 deletions(-) delete mode 100644 webpack/hacks/cesium/README.md delete mode 100644 webpack/hacks/cesium/buildModuleUrl.js.modified delete mode 100644 webpack/hacks/postinstall.js diff --git a/package.json b/package.json index 81469de0e8..9bcb274960 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,7 @@ "lint": "eslint . --quiet", "test": "eslint . --quiet && jest", "test:coverage": "jest --coverage", - "test:watch": "jest --watch", - "postinstall": "node webpack/hacks/postinstall.js" + "test:watch": "jest --watch" }, "dependencies": { "@ant-design/icons": "5.5.1", @@ -95,6 +94,7 @@ "webpack": "4.47.0", "webpack-cli": "4.10.0", "webpack-dev-server": "4.15.2", - "webpackbar": "5.0.2" + "webpackbar": "5.0.2", + "@open-wc/webpack-import-meta-loader": "^0.4.7" } } diff --git a/webpack/config.js b/webpack/config.js index 3e2ba38c8f..26718abb42 100644 --- a/webpack/config.js +++ b/webpack/config.js @@ -122,6 +122,10 @@ const BABEL_LOADER_RULE = { const getModuleRules = (isProd = false, antThemeFile) => { const styleFileRules = getStyleFileRules(isProd, antThemeFile); const rules = [ + { + test: /\.js$/, + loader: require.resolve('@open-wc/webpack-import-meta-loader') + }, { test: require.resolve('sumoselect'), use: [{ diff --git a/webpack/hacks/cesium/README.md b/webpack/hacks/cesium/README.md deleted file mode 100644 index 8e1bfea2ad..0000000000 --- a/webpack/hacks/cesium/README.md +++ /dev/null @@ -1,25 +0,0 @@ -`buildModuleUrl.js.modified` is a copy of `node_modules/@cesium/engine/Source/Core/buildModuleUrl.js` and is overwriting the original version with as a postinstall script. - -The changes are tagged with `// EDIT START` and `// EDIT END`. - -Commented out part where import.meta?.url is referenced as Webpack 4.x fails to process it with this error: - -```sh -ERROR in ../oskari-frontend/node_modules/@cesium/engine/Source/Core/buildModuleUrl.js 42:43 -Module parse failed: Unexpected token (42:43) -File was processed with these loaders: - * ../oskari-frontend/node_modules/babel-loader/lib/index.js -You may need an additional loader to handle the result of these loaders. -| if (typeof CESIUM_BASE_URL !== "undefined") { -| baseUrlString = CESIUM_BASE_URL; -> } else if (defined((_import$meta = import.meta) === null || _import$meta === void 0 ? void 0 : _import$meta.url)) { -| // ESM -| baseUrlString = getAbsoluteUri(".", import.meta.url); - @ ../oskari-frontend/node_modules/@cesium/engine/Source/Core/ApproximateTerrainHeights.js 2:0-49 39:35-49 - @ ../oskari-frontend/node_modules/@cesium/engine/index.js - @ ../oskari-frontend/node_modules/cesium/Source/Cesium.js - @ ./node_modules/oskari-frontend/bundles/mapping/mapmodule/mapmodule.olcs.js - @ ../oskari-frontend/webpack/oskariLoader.js!./node_modules/oskari-frontend/packages/mapping/olcs/mapmodule/bundle.js - @ ./applications/embedded-3D/main.js - @ multi ../oskari-frontend/webpack/polyfill.js ../oskari-frontend/webpack/oskari-core.js ./applications/embedded-3D/main.js - ``` diff --git a/webpack/hacks/cesium/buildModuleUrl.js.modified b/webpack/hacks/cesium/buildModuleUrl.js.modified deleted file mode 100644 index 749d451f1f..0000000000 --- a/webpack/hacks/cesium/buildModuleUrl.js.modified +++ /dev/null @@ -1,158 +0,0 @@ -import defined from "./defined.js"; -import DeveloperError from "./DeveloperError.js"; -import getAbsoluteUri from "./getAbsoluteUri.js"; -import Resource from "./Resource.js"; - -/*global CESIUM_BASE_URL,define,require*/ - -const cesiumScriptRegex = /((?:.*\/)|^)Cesium\.js(?:\?|\#|$)/; -function getBaseUrlFromCesiumScript() { - const scripts = document.getElementsByTagName("script"); - for (let i = 0, len = scripts.length; i < len; ++i) { - const src = scripts[i].getAttribute("src"); - const result = cesiumScriptRegex.exec(src); - if (result !== null) { - return result[1]; - } - } - return undefined; -} - -let a; -function tryMakeAbsolute(url) { - if (typeof document === "undefined") { - // Node.js and Web Workers. In both cases, the URL will already be absolute. - return url; - } - - if (!defined(a)) { - a = document.createElement("a"); - } - a.href = url; - return a.href; -} - -let baseResource; -function getCesiumBaseUrl() { - if (defined(baseResource)) { - return baseResource; - } - - let baseUrlString; - if (typeof CESIUM_BASE_URL !== "undefined") { - baseUrlString = CESIUM_BASE_URL; - } -// EDIT START - /* - else if (defined(import.meta?.url)) { - // ESM - baseUrlString = getAbsoluteUri(".", import.meta.url); - } else if ( - typeof define === "object" && - defined(define.amd) && - !define.amd.toUrlUndefined && - defined(require.toUrl) - ) { - // RequireJS - baseUrlString = getAbsoluteUri( - "..", - buildModuleUrl("Core/buildModuleUrl.js") - ); - } else { - // IIFE - baseUrlString = getBaseUrlFromCesiumScript(); - } - */ -// EDIT END - - //>>includeStart('debug', pragmas.debug); - if (!defined(baseUrlString)) { - throw new DeveloperError( - "Unable to determine Cesium base URL automatically, try defining a global variable called CESIUM_BASE_URL." - ); - } - //>>includeEnd('debug'); - - baseResource = new Resource({ - url: tryMakeAbsolute(baseUrlString), - }); - baseResource.appendForwardSlash(); - - return baseResource; -} - -function buildModuleUrlFromRequireToUrl(moduleID) { - //moduleID will be non-relative, so require it relative to this module, in Core. - return tryMakeAbsolute(require.toUrl(`../${moduleID}`)); -} - -function buildModuleUrlFromBaseUrl(moduleID) { - const resource = getCesiumBaseUrl().getDerivedResource({ - url: moduleID, - }); - return resource.url; -} - -let implementation; - -/** - * Given a relative URL under the Cesium base URL, returns an absolute URL. - * @function - * - * @param {string} relativeUrl The relative path. - * @returns {string} The absolutely URL representation of the provided path. - * - * @example - * const viewer = new Cesium.Viewer("cesiumContainer", { - * baseLayer: Cesium.ImageryLayer.fromProviderAsync( - * Cesium.TileMapServiceImageryProvider.fromUrl( - * Cesium.buildModuleUrl("Assets/Textures/NaturalEarthII"), - * )), - * baseLayerPicker: false, - * }); - */ -function buildModuleUrl(relativeUrl) { - if (!defined(implementation)) { - //select implementation - if ( - typeof define === "object" && - defined(define.amd) && - !define.amd.toUrlUndefined && - defined(require.toUrl) - ) { - implementation = buildModuleUrlFromRequireToUrl; - } else { - implementation = buildModuleUrlFromBaseUrl; - } - } - - const url = implementation(relativeUrl); - return url; -} - -// exposed for testing -buildModuleUrl._cesiumScriptRegex = cesiumScriptRegex; -buildModuleUrl._buildModuleUrlFromBaseUrl = buildModuleUrlFromBaseUrl; -buildModuleUrl._clearBaseResource = function () { - baseResource = undefined; -}; - -/** - * Sets the base URL for resolving modules. - * @param {string} value The new base URL. - */ -buildModuleUrl.setBaseUrl = function (value) { - baseResource = Resource.DEFAULT.getDerivedResource({ - url: value, - }); -}; - -/** - * Gets the base URL for resolving modules. - * - * @function - * @returns {string} The configured base URL - */ -buildModuleUrl.getCesiumBaseUrl = getCesiumBaseUrl; - -export default buildModuleUrl; diff --git a/webpack/hacks/postinstall.js b/webpack/hacks/postinstall.js deleted file mode 100644 index e7e3aafe4b..0000000000 --- a/webpack/hacks/postinstall.js +++ /dev/null @@ -1,19 +0,0 @@ -const fs = require('fs-extra'); -const path = require('path'); - -const srcFileCesiumHack = path.join(__dirname, 'cesium', 'buildModuleUrl.js.modified'); -// installed as ../oskari-frontend -let pathToCesium = path.join(__dirname, '..', '..', 'node_modules', '@cesium'); -if (!fs.existsSync(pathToCesium)) { - // installed in non-dev-mode - pathToCesium = path.join(__dirname, '..', '..', '@cesium'); -} -// try again with non-dev-mode -if (!fs.existsSync(pathToCesium)) { - // something went terribly wrong -} else { - // Overwrites node_modules/@cesium/engine/Source/Core/buildModuleUrl.js - // with a modified on to fix issues with Webpack 4.x - const destFileCesiumHack = path.join(pathToCesium, 'engine', 'Source', 'Core', 'buildModuleUrl.js'); - fs.copyFile(srcFileCesiumHack, destFileCesiumHack); -} From f6cb2588b08befeb76f727873cb9ac8e6ec23149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kinen?= Date: Fri, 13 Dec 2024 13:42:06 +0200 Subject: [PATCH 6/8] Update webpack/config.js --- webpack/config.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/webpack/config.js b/webpack/config.js index 26718abb42..ee40c2a8bc 100644 --- a/webpack/config.js +++ b/webpack/config.js @@ -122,6 +122,11 @@ const BABEL_LOADER_RULE = { const getModuleRules = (isProd = false, antThemeFile) => { const styleFileRules = getStyleFileRules(isProd, antThemeFile); const rules = [ +/* +webpack-import-meta-loader fixes this error for building Cesium: +ERROR in ../oskari-frontend/node_modules/@cesium/engine/Source/Core/buildModuleUrl.js 42:43 +Module parse failed: Unexpected token (42:43) +*/ { test: /\.js$/, loader: require.resolve('@open-wc/webpack-import-meta-loader') From 0f98f0b5f9b13cb024c0b677cbfaa45f0941c923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kinen?= Date: Fri, 13 Dec 2024 14:10:52 +0200 Subject: [PATCH 7/8] Make ESLint happy --- webpack/config.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/webpack/config.js b/webpack/config.js index ee40c2a8bc..90da5ac4fc 100644 --- a/webpack/config.js +++ b/webpack/config.js @@ -122,11 +122,11 @@ const BABEL_LOADER_RULE = { const getModuleRules = (isProd = false, antThemeFile) => { const styleFileRules = getStyleFileRules(isProd, antThemeFile); const rules = [ -/* -webpack-import-meta-loader fixes this error for building Cesium: -ERROR in ../oskari-frontend/node_modules/@cesium/engine/Source/Core/buildModuleUrl.js 42:43 -Module parse failed: Unexpected token (42:43) -*/ + /* + webpack-import-meta-loader fixes this error for building Cesium: + ERROR in ../oskari-frontend/node_modules/@cesium/engine/Source/Core/buildModuleUrl.js 42:43 + Module parse failed: Unexpected token (42:43) + */ { test: /\.js$/, loader: require.resolve('@open-wc/webpack-import-meta-loader') From ced602165955022a3c6b702713b1dcf7c0f93b22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kinen?= Date: Fri, 13 Dec 2024 14:11:42 +0200 Subject: [PATCH 8/8] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9bcb274960..750a2b93ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oskari-frontend", - "version": "2.14.0", + "version": "2.14.1", "description": "Oskari frontend", "keywords": [ "oskari",