Skip to content

Commit

Permalink
Added logic to sanitize Image and Action columns
Browse files Browse the repository at this point in the history
  • Loading branch information
gnbm committed Aug 20, 2024
1 parent e8da103 commit 9f4d720
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Providers/DataGrid/Wijmo/Columns/ActionColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/Providers/DataGrid/Wijmo/Columns/ImageColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 10 additions & 2 deletions src/Providers/DataGrid/Wijmo/Helper/CellTemplateFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,27 @@ 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;

const hasFixedText = binding.startsWith('$');
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 + '}';
}

Expand Down

0 comments on commit 9f4d720

Please sign in to comment.