@geogirafe/lib-geoportal 1.2.0-dev.2681709337 → 1.2.0-dev.2682051281

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@ import ColumnAliasHelper from '../../../tools/utils/aliases.js';
5
5
  import { linkify } from '../../../tools/utils/utils.js';
6
6
  import { noop } from '../../../tools/utils/async.js';
7
7
  import tippy from 'tippy.js';
8
- import { sanitize } from '../../../tools/utils/selection.js';
8
+ import { sanitize } from '../../../tools/utils/sanitize.js';
9
9
  const geometryColumns = new Set(['geom', 'the_geom', 'geometry']);
10
10
  export default class SelectionTabulatorManager {
11
11
  featureToGridData;
@@ -8,7 +8,7 @@ import IconCenter from './images/center.svg';
8
8
  import ResizeWindow from '../../tools/resizewindow.js';
9
9
  import CsvManager from '../../tools/export/csvmanager.js';
10
10
  import ColumnAliasHelper from '../../tools/utils/aliases.js';
11
- import { sanitize } from '../../tools/utils/selection.js';
11
+ import { sanitize } from '../../tools/utils/sanitize.js';
12
12
  /**
13
13
  * Represents a draggable and resizable selection window component.
14
14
  * Display itself when it should be visible and have selected features.
@@ -72,7 +72,12 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
72
72
  return;
73
73
  }
74
74
  this.iconUrl = this.wmsLegendHelper.getIconUrl(this.layer);
75
- this.legendUrls = this.wmsLegendHelper.getLegendUrls(this.layer);
75
+ if (this.isVisibleInCurrentResolution()) {
76
+ this.legendUrls = this.wmsLegendHelper.getLegendUrls(this.layer);
77
+ }
78
+ else {
79
+ this.legendUrls = {};
80
+ }
76
81
  }
77
82
  setWmtsLegend() {
78
83
  if (!(this.layer instanceof LayerWmts)) {
@@ -208,7 +213,7 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
208
213
  }
209
214
  const currentResolution = this.state.position.resolution;
210
215
  if (currentResolution) {
211
- return this.layer.isVisibleAtResolution(this.state.position.resolution);
216
+ return this.layer.isVisibleAtResolution(currentResolution);
212
217
  }
213
218
  return false;
214
219
  }
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "name": "GeoGirafe PSC",
6
6
  "url": "https://doc.geogirafe.org"
7
7
  },
8
- "version": "1.2.0-dev.2681709337",
8
+ "version": "1.2.0-dev.2682051281",
9
9
  "type": "module",
10
10
  "engines": {
11
11
  "node": ">=20.19.0"
@@ -1 +1 @@
1
- {"version":"1.2.0-dev.2681709337", "build":"2681709337", "date":"16/07/2026"}
1
+ {"version":"1.2.0-dev.2682051281", "build":"2682051281", "date":"16/07/2026"}
package/tools/main.d.ts CHANGED
@@ -133,7 +133,7 @@ export { default as GirafeColorPicker } from './utils/girafecolorpicker.js';
133
133
  export { unByKeyAll, getOlayerByName, removeUnwantedOlParams, polygonFromCircle, getDistance, getAreaOfPolygon, getAreaOfCircle, isCoordinateInDegrees, getSelectionBoxFromMapClick, reprojectGeometry, ensurePolygonIsProperlyClosed, getHalfPoint, getLabelStyle, getRadiusDataForCircle, getLengthAsMetricText, getAreaAsMetricText, getAzimuthAsText } from './utils/olutils.js';
134
134
  export { getPropertyByPath, setPropertyByPath, createObjectFromPath, deletePropertyByPath, mergeObjects } from './utils/pathUtils.js';
135
135
  export { generateQrCode } from './utils/qrcode.js';
136
- export { sanitize } from './utils/selection.js';
136
+ export { sanitize } from './utils/sanitize.js';
137
137
  export { default as ServiceWorkerHelper } from './utils/swhelper.js';
138
138
  export { systemIsInDarkMode, isSafari, isFirefox, getValidIndex, minMax, hexToRgbaArray, rgbStrToRgbaArray, colorToRgbaArray, isValidEmail, applyOpacityToLayers, applyFeaturesToSelection, linkify, applyDefaultPrefixToUrl, splitTrimAndConvertToNumber } from './utils/utils.js';
139
139
  export { default as VendorSpecificOgcServerManager } from './vendorspecificogcservermanager.js';
package/tools/main.js CHANGED
@@ -100,7 +100,7 @@ export { default as GirafeColorPicker } from './utils/girafecolorpicker.js';
100
100
  export { unByKeyAll, getOlayerByName, removeUnwantedOlParams, polygonFromCircle, getDistance, getAreaOfPolygon, getAreaOfCircle, isCoordinateInDegrees, getSelectionBoxFromMapClick, reprojectGeometry, ensurePolygonIsProperlyClosed, getHalfPoint, getLabelStyle, getRadiusDataForCircle, getLengthAsMetricText, getAreaAsMetricText, getAzimuthAsText } from './utils/olutils.js';
101
101
  export { getPropertyByPath, setPropertyByPath, createObjectFromPath, deletePropertyByPath, mergeObjects } from './utils/pathUtils.js';
102
102
  export { generateQrCode } from './utils/qrcode.js';
103
- export { sanitize } from './utils/selection.js';
103
+ export { sanitize } from './utils/sanitize.js';
104
104
  export { default as ServiceWorkerHelper } from './utils/swhelper.js';
105
105
  export { systemIsInDarkMode, isSafari, isFirefox, getValidIndex, minMax, hexToRgbaArray, rgbStrToRgbaArray, colorToRgbaArray, isValidEmail, applyOpacityToLayers, applyFeaturesToSelection, linkify, applyDefaultPrefixToUrl, splitTrimAndConvertToNumber } from './utils/utils.js';
106
106
  export { default as VendorSpecificOgcServerManager } from './vendorspecificogcservermanager.js';
@@ -22,6 +22,9 @@ export declare const MockConfig: {
22
22
  'EPSG:2056': string;
23
23
  'EPSG:3857': string;
24
24
  };
25
+ query: {
26
+ legacy: boolean;
27
+ };
25
28
  map: {
26
29
  srid: string;
27
30
  scales: number[];
@@ -23,6 +23,9 @@ export const MockConfig = {
23
23
  'EPSG:2056': 'LV95',
24
24
  'EPSG:3857': 'W-M'
25
25
  },
26
+ query: {
27
+ legacy: true
28
+ },
26
29
  map: {
27
30
  srid: 'EPSG:2056',
28
31
  scales: [1000000, 500000, 200000, 100000, 50000, 20000, 10000, 5000, 2000, 1000, 500, 200],
@@ -0,0 +1,7 @@
1
+ import GirafeConfig from '../configuration/girafeconfig.js';
2
+ /**
3
+ * Use DOMPurify.sanitize to remove potentially harmful html/js code.
4
+ * @param unsanitized the raw text to sanitize.
5
+ * @param config Allowed tags and elements in a string.
6
+ */
7
+ export declare const sanitize: (unsanitized: string, config: GirafeConfig) => string;
@@ -0,0 +1,74 @@
1
+ import DOMPurify from 'dompurify';
2
+ /**
3
+ * Use DOMPurify.sanitize to remove potentially harmful html/js code.
4
+ * @param unsanitized the raw text to sanitize.
5
+ * @param config Allowed tags and elements in a string.
6
+ */
7
+ export const sanitize = (unsanitized, config) => {
8
+ let sanitizeConfig = {
9
+ ...config.query.sanitizeConfig
10
+ };
11
+ if (config.query.legacy) {
12
+ sanitizeConfig = {
13
+ ...sanitizeConfig,
14
+ ADD_ATTR: ['onclick', 'data-gopenwindow'],
15
+ ADD_URI_SAFE_ATTR: ['onclick']
16
+ };
17
+ }
18
+ if (unsanitized.includes('gOpenWindow')) {
19
+ const unsanitizedWithDataGOpenWindow = transformOpenWindowLinksToData(unsanitized);
20
+ const sanitized = DOMPurify.sanitize(unsanitizedWithDataGOpenWindow, sanitizeConfig);
21
+ return transformDataOpenWindowToLinks(sanitized);
22
+ }
23
+ return DOMPurify.sanitize(unsanitized, sanitizeConfig);
24
+ };
25
+ /** A join tmp marker used to split again a string. */
26
+ const gOpenWindowSplitArgChar = '°°°';
27
+ /**
28
+ * Transforms a text (link) with <a href="javascript:gOpenWindow(args)">text</a> to a text without href and
29
+ * with a new "data-gopenwindow='args'". This allows sanitizing a string and keeping the
30
+ * GOpenWindow function arguments.
31
+ */
32
+ const transformOpenWindowLinksToData = (text) => {
33
+ // Long regexp because we want to capture all arguments, 4 are optional and can be text or number.
34
+ // Title and or url can contain any character, including comma.
35
+ const gOpenWindowLinkRegExp = /<a\b[^>]*\bhref\s*=\s*"javascript:(?:window\.)?gOpenWindow\(\s*'([^']*)'\s*,\s*'([^']*)'(?:\s*,\s*(?:'([^']*)'|(\d+)))?(?:\s*,\s*(?:'([^']*)'|(\d+)))?(?:\s*,\s*(?:'([^']*)'|(\d+)))?(?:\s*,\s*(?:'([^']*)'|(\d+)))?\s*\)\s*;"[^>]*>([\s\S]*?)<\/a>/gi;
36
+ return text.replace(gOpenWindowLinkRegExp, (_, title, url, widthText, widthNumber, heightText, heightNumber, topText, topNumber, leftText, leftNumber, text) => {
37
+ const width = widthText ? `'${widthText}'` : widthNumber;
38
+ const height = heightText ? `'${heightText}'` : heightNumber;
39
+ const top = topText ? `'${topText}'` : topNumber;
40
+ const left = leftText ? `'${leftText}'` : leftNumber;
41
+ const gOpenWindowArgs = [title, url];
42
+ if (width)
43
+ gOpenWindowArgs.push(width);
44
+ if (height)
45
+ gOpenWindowArgs.push(height);
46
+ if (top)
47
+ gOpenWindowArgs.push(top);
48
+ if (left)
49
+ gOpenWindowArgs.push(left);
50
+ return `<a data-gopenwindow="${gOpenWindowArgs.join(gOpenWindowSplitArgChar)}">${text}</a>`;
51
+ });
52
+ };
53
+ /**
54
+ * Transforms a text (link) with a new "data-gopenwindow='args'" to a text like
55
+ * <a href="javascript:gOpenWindow(args)">text</a>.The args are split by
56
+ * the gOpenWindowSplitArgChar.
57
+ */
58
+ const transformDataOpenWindowToLinks = (text) => {
59
+ const gOpenWindowDataRegExp = /<a\s+data-gopenwindow="([^"]*)">([^"]*)<\/a>/gi;
60
+ return text.replace(gOpenWindowDataRegExp, (_, data, text) => {
61
+ const [title, url, width, height, top, left] = data.split(gOpenWindowSplitArgChar);
62
+ const urlParts = [`<a href="javascript:gOpenWindow('${title}', '${url}'`];
63
+ if (width)
64
+ urlParts.push(`, ${width}`);
65
+ if (height)
66
+ urlParts.push(`, ${height}`);
67
+ if (top)
68
+ urlParts.push(`, ${top}`);
69
+ if (left)
70
+ urlParts.push(`, ${left}`);
71
+ urlParts.push(`);">${text}</a>`);
72
+ return urlParts.join('');
73
+ });
74
+ };
@@ -1,2 +0,0 @@
1
- import GirafeConfig from '../configuration/girafeconfig.js';
2
- export declare const sanitize: (unsanitized: string, config: GirafeConfig) => string;
@@ -1,14 +0,0 @@
1
- import DOMPurify from 'dompurify';
2
- export const sanitize = (unsanitized, config) => {
3
- let sanitizeConfig = {
4
- ...config.query.sanitizeConfig
5
- };
6
- if (config.query.legacy) {
7
- sanitizeConfig = {
8
- ...sanitizeConfig,
9
- ADD_ATTR: ['onclick'],
10
- ADD_URI_SAFE_ATTR: ['onclick']
11
- };
12
- }
13
- return DOMPurify.sanitize(unsanitized, sanitizeConfig);
14
- };