Skip to content

Commit

Permalink
Sanitize HTML on grid HTML widget
Browse files Browse the repository at this point in the history
  • Loading branch information
pdo-axelor committed Jan 27, 2025
1 parent ea6d4f2 commit e141366
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions axelor-web/src/main/webapp/js/form/form.input.html.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,15 @@ ui.formInput('HtmlInline', 'Text', {
var shellElement = $(shell.getElement());
wrapper.resizable();

scope.$render_editable = function () {
var value = scope.getValue() || "";
var sanitizedValue = axelor.sanitize(value);
if (DOMPurify.removed.length) {
value = sanitizedValue;
model.$setViewValue(value);
}
};

scope.waitForActions(function() {
container = element.parents('.ui-dialog-content,.view-container').first();
wrapper.height(field.height || 175).appendTo(container);
Expand Down
2 changes: 1 addition & 1 deletion axelor-web/src/main/webapp/js/widget/widget.slickgrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ _.extend(Factory.prototype, {
}

if (widget === "html") {
return value ? '<span>' + value + '</span>' : '';
return value ? '<span>' + axelor.sanitize(value) + '</span>' : '';
}

// try to get dotted field value from related object
Expand Down
4 changes: 4 additions & 0 deletions changelogs/unreleased/security-html-widget-grid.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

---
title: Sanitize HTML on grid HTML widget
type: security

0 comments on commit e141366

Please sign in to comment.