Skip to content

Commit f7cd5c0

Browse files
DataGrid: replace html data with string for security (#32492)
1 parent 862acb4 commit f7cd5c0

17 files changed

Lines changed: 935 additions & 937 deletions

File tree

apps/demos/Demos/DataGrid/FocusedRow/Angular/app/app.component.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
font-size: 14px;
2222
margin-top: 0;
2323
margin-bottom: 0;
24+
white-space: pre-line;
2425
}
2526

2627
.progress {

apps/demos/Demos/DataGrid/FocusedRow/Angular/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<div class="task-info">
2727
<div class="info">
2828
<div id="taskSubject">{{ taskSubject }}</div>
29-
<p id="taskDetails" [innerHtml]="taskDetailsHtml"></p>
29+
<p id="taskDetails">{{ taskDetails }}</p>
3030
</div>
3131
<div class="progress">
3232
<span id="taskStatus">{{ taskStatus }}</span>

apps/demos/Demos/DataGrid/FocusedRow/Angular/app/app.component.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { bootstrapApplication,
2-
DomSanitizer, SafeHtml } from '@angular/platform-browser';
1+
import { bootstrapApplication } from '@angular/platform-browser';
32
import { Component, ViewChild, enableProdMode, provideZoneChangeDetection } from '@angular/core';
43

54
import { DxNumberBoxComponent, DxNumberBoxModule, DxCheckBoxModule } from 'devextreme-angular';
@@ -37,7 +36,7 @@ export class AppComponent {
3736

3837
taskSubject: string;
3938

40-
taskDetailsHtml: SafeHtml;
39+
taskDetails: string;
4140

4241
taskStatus: string;
4342

@@ -72,7 +71,7 @@ export class AppComponent {
7271
},
7372
];
7473

75-
constructor(private sanitizer: DomSanitizer, service: Service) {
74+
constructor(service: Service) {
7675
this.dataSource = new DataSource({
7776
store: new ArrayStore({
7877
data: service.getTasks(),
@@ -103,7 +102,7 @@ export class AppComponent {
103102
onFocusedRowChanged(e: DxDataGridTypes.FocusedRowChangedEvent<Task, number>) {
104103
const data = e.row?.data;
105104
this.taskSubject = data?.Task_Subject ?? '';
106-
this.taskDetailsHtml = this.sanitizer.bypassSecurityTrustHtml(data?.Task_Description ?? '');
105+
this.taskDetails = data?.Task_Description ?? '';
107106
this.taskStatus = data?.Task_Status ?? '';
108107
this.taskProgress = data?.Task_Completion ? `${data?.Task_Completion}%` : '';
109108
}

apps/demos/Demos/DataGrid/FocusedRow/Angular/app/app.service.ts

Lines changed: 183 additions & 183 deletions
Large diffs are not rendered by default.

apps/demos/Demos/DataGrid/FocusedRow/React/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const App = () => {
102102
<div className="task-info">
103103
<div className="info">
104104
<div id="taskSubject">{taskSubject}</div>
105-
<p id="taskDetails" dangerouslySetInnerHTML={{ __html: taskDetails }}></p>
105+
<p id="taskDetails">{taskDetails}</p>
106106
</div>
107107
<div className="progress">
108108
<span id="taskStatus">{taskStatus}</span>

apps/demos/Demos/DataGrid/FocusedRow/React/data.ts

Lines changed: 183 additions & 183 deletions
Large diffs are not rendered by default.

apps/demos/Demos/DataGrid/FocusedRow/React/styles.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
font-size: 14px;
2222
margin-top: 0;
2323
margin-bottom: 0;
24+
white-space: pre-line;
2425
}
2526

2627
.progress {

apps/demos/Demos/DataGrid/FocusedRow/ReactJs/App.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,7 @@ const App = () => {
9797
<div className="task-info">
9898
<div className="info">
9999
<div id="taskSubject">{taskSubject}</div>
100-
<p
101-
id="taskDetails"
102-
dangerouslySetInnerHTML={{ __html: taskDetails }}
103-
></p>
100+
<p id="taskDetails">{taskDetails}</p>
104101
</div>
105102
<div className="progress">
106103
<span id="taskStatus">{taskStatus}</span>

apps/demos/Demos/DataGrid/FocusedRow/ReactJs/data.js

Lines changed: 183 additions & 183 deletions
Large diffs are not rendered by default.

apps/demos/Demos/DataGrid/FocusedRow/ReactJs/styles.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
font-size: 14px;
2222
margin-top: 0;
2323
margin-bottom: 0;
24+
white-space: pre-line;
2425
}
2526

2627
.progress {

0 commit comments

Comments
 (0)