diff --git a/src/OSFramework/DataGrid/Configuration/Grid/FlexGridConfig.ts b/src/OSFramework/DataGrid/Configuration/Grid/FlexGridConfig.ts index d259d433..441a8769 100644 --- a/src/OSFramework/DataGrid/Configuration/Grid/FlexGridConfig.ts +++ b/src/OSFramework/DataGrid/Configuration/Grid/FlexGridConfig.ts @@ -19,6 +19,7 @@ namespace OSFramework.DataGrid.Configuration.Grid { public rowHeader: Enum.RowHeader; public rowHeight: number; public rowsPerPage: number; + public sanitizeInputValues: boolean; public selectionMode: number; public serverSidePagination: boolean; public showAggregateValues: boolean; diff --git a/src/OSFramework/DataGrid/Configuration/IConfigurationGrid.ts b/src/OSFramework/DataGrid/Configuration/IConfigurationGrid.ts index 8c4d400d..8b580fe6 100644 --- a/src/OSFramework/DataGrid/Configuration/IConfigurationGrid.ts +++ b/src/OSFramework/DataGrid/Configuration/IConfigurationGrid.ts @@ -22,6 +22,10 @@ namespace OSFramework.DataGrid.Configuration { */ keyBinding: string; /** + * Indicates if the grid should sanitize the input values or not + */ + sanitizeInputValues: boolean; + /** Indicates if the grid is in server side pagination mode */ serverSidePagination: boolean; diff --git a/src/OutSystems/GridAPI/GridManager.ts b/src/OutSystems/GridAPI/GridManager.ts index 27f8b509..e12d00e5 100644 --- a/src/OutSystems/GridAPI/GridManager.ts +++ b/src/OutSystems/GridAPI/GridManager.ts @@ -15,6 +15,10 @@ namespace OutSystems.GridAPI.GridManager { let output = false; if (grid !== undefined) { if (grid.isReady && data !== '' && data !== '{}') { + // When the configurantion is set to sanitize the input values, we need to sanitize the data before setting it + if (grid.config.sanitizeInputValues) { + data = OSFramework.DataGrid.Helper.Sanitize(data); + } grid.setData(data); } output = true; diff --git a/src/Providers/DataGrid/Wijmo/Columns/ActionColumn.ts b/src/Providers/DataGrid/Wijmo/Columns/ActionColumn.ts index ef005abb..614c06fc 100644 --- a/src/Providers/DataGrid/Wijmo/Columns/ActionColumn.ts +++ b/src/Providers/DataGrid/Wijmo/Columns/ActionColumn.ts @@ -37,7 +37,8 @@ namespace Providers.DataGrid.Wijmo.Column { config.binding, this.handleActionEvent.bind(this), undefined, - this.config.externalURL + this.config.externalURL, + this.grid.config.sanitizeInputValues ); return config; diff --git a/src/Providers/DataGrid/Wijmo/Columns/ImageColumn.ts b/src/Providers/DataGrid/Wijmo/Columns/ImageColumn.ts index e67b1162..bb4b1378 100644 --- a/src/Providers/DataGrid/Wijmo/Columns/ImageColumn.ts +++ b/src/Providers/DataGrid/Wijmo/Columns/ImageColumn.ts @@ -36,7 +36,9 @@ namespace Providers.DataGrid.Wijmo.Column { this.config.actionColumnElementType, config.binding, this.handleActionEvent.bind(this), - this.config.altText + this.config.altText, + undefined /* externalURL */, + this.grid.config.sanitizeInputValues ); return config; diff --git a/src/Providers/DataGrid/Wijmo/Features/ContextMenu.ts b/src/Providers/DataGrid/Wijmo/Features/ContextMenu.ts index f037b727..37dd84ef 100644 --- a/src/Providers/DataGrid/Wijmo/Features/ContextMenu.ts +++ b/src/Providers/DataGrid/Wijmo/Features/ContextMenu.ts @@ -313,8 +313,8 @@ namespace Providers.DataGrid.Wijmo.Feature { executeCommand: OSFramework.DataGrid.Callbacks.ContextMenu.OSClickEvent ): void { const menuItem = new OSFramework.DataGrid.Feature.Auxiliar.MenuItem(menuItemId); - - menuItem.label = label; + // Sanitize the label if the configuration is set to do so + menuItem.label = this.grid.config.sanitizeInputValues ? OSFramework.DataGrid.Helper.Sanitize(label) : label; menuItem.enabled = enabled; menuItem.clickEvent = executeCommand; @@ -339,7 +339,12 @@ namespace Providers.DataGrid.Wijmo.Feature { const menuItem = this._menuItems.get(menuItemId); if (menuItem) { if (menuItem.hasOwnProperty(propertyName)) { - menuItem[propertyName] = propertyValue; + if (propertyName === 'label' && this.grid.config.sanitizeInputValues) { + // Sanitize the label if the configuration is set to do so + menuItem.label = OSFramework.DataGrid.Helper.Sanitize(propertyValue as string); + } else { + menuItem[propertyName] = propertyValue; + } } else { console.error(`MenuItem "${menuItem.label}" has no property "${propertyName}" defined.`); } diff --git a/src/Providers/DataGrid/Wijmo/Helper/CellTemplateFactory.ts b/src/Providers/DataGrid/Wijmo/Helper/CellTemplateFactory.ts index fe7b01cc..5448a7c8 100644 --- a/src/Providers/DataGrid/Wijmo/Helper/CellTemplateFactory.ts +++ b/src/Providers/DataGrid/Wijmo/Helper/CellTemplateFactory.ts @@ -11,7 +11,8 @@ namespace Providers.DataGrid.Wijmo.Helper.CellTemplateFactory { binding: string, callback: (item) => void, altText?: string, - externalURL?: string + externalURL?: string, + sanitizeInputValues?: boolean ): wijmo.grid.ICellTemplateFunction { let cellTemplate: wijmo.grid.ICellTemplateFunction; @@ -19,11 +20,18 @@ namespace Providers.DataGrid.Wijmo.Helper.CellTemplateFactory { const hasExternalURL = externalURL?.toLocaleLowerCase().startsWith('http'); const url = hasExternalURL ? externalURL : '${item.' + externalURL + '}'; - const text = hasFixedText ? binding.substring(1) : undefined; + let text = hasFixedText ? binding.substring(1) : undefined; + + // Sanitize the text if the configuration is set to do so + if (text !== undefined) { + text = sanitizeInputValues ? OSFramework.DataGrid.Helper.Sanitize(text) : text; + } let imgAltText = ''; if (altText !== undefined) { const hasFixedAltText = altText.startsWith('$'); + // Sanitize the alternative text if the configuration is set to do so + altText = sanitizeInputValues ? OSFramework.DataGrid.Helper.Sanitize(altText) : altText; imgAltText = hasFixedAltText ? altText.substring(1) : '${item.' + altText + '}'; }