Skip to content

Commit 9e260f4

Browse files
Mattia VianelliAndrea Barbasso
authored andcommitted
Merged in task/dspace-cris-2024_02_x/DSC-2212 (pull request DSpace#3868)
Task/dspace cris 2024 02 x/DSC-2212 Approved-by: Andrea Barbasso
2 parents fa39e87 + f59cce6 commit 9e260f4

File tree

15 files changed

+46
-15
lines changed

15 files changed

+46
-15
lines changed

src/app/breadcrumbs/breadcrumbs.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
</ng-template>
1515

1616
<ng-template #activeBreadcrumb let-text="text">
17-
<li class="breadcrumb-item active" aria-current="page"><div class="breadcrumb-item-limiter"><span class="text-truncate" [innerHTML]="text | translate"></span></div></li>
17+
<li class="breadcrumb-item active" aria-current="page"><div class="breadcrumb-item-limiter"><span class="text-truncate" [innerHTML]="text | translate | dsEscapeHtml"></span></div></li>
1818
</ng-template>
1919
</ng-container>
20-

src/app/breadcrumbs/breadcrumbs.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';
1010
import { TranslateModule } from '@ngx-translate/core';
1111
import { Observable } from 'rxjs';
1212

13+
import { EscapeHtmlPipe } from '../shared/utils/escape-html.pipe';
1314
import { VarDirective } from '../shared/utils/var.directive';
1415
import { Breadcrumb } from './breadcrumb/breadcrumb.model';
1516
import { BreadcrumbsService } from './breadcrumbs.service';
@@ -22,7 +23,7 @@ import { BreadcrumbsService } from './breadcrumbs.service';
2223
templateUrl: './breadcrumbs.component.html',
2324
styleUrls: ['./breadcrumbs.component.scss'],
2425
standalone: true,
25-
imports: [VarDirective, NgIf, NgTemplateOutlet, NgFor, RouterLink, NgbTooltipModule, AsyncPipe, TranslateModule],
26+
imports: [VarDirective, NgIf, NgTemplateOutlet, NgFor, RouterLink, NgbTooltipModule, AsyncPipe, TranslateModule, EscapeHtmlPipe],
2627
})
2728
export class BreadcrumbsComponent {
2829

src/app/cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/longtext/longtext.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="{{field.styleValue}}">
33
<ds-truncatable [id]="truncableId">
44
<ds-truncatable-part [id]="truncableId" [minLines]="3">
5-
<span [innerHTML]="formatText(metadataValue.value)" data-test="formatted-text"></span>
5+
<span [innerHTML]="metadataValue.value | dsEscapeHtml" data-test="formatted-text"></span>
66
</ds-truncatable-part>
77
</ds-truncatable>
88
</div>

src/app/cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/longtext/longtext.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Component } from '@angular/core';
22

33
import { TruncatableComponent } from '../../../../../../../shared/truncatable/truncatable.component';
44
import { TruncatablePartComponent } from '../../../../../../../shared/truncatable/truncatable-part/truncatable-part.component';
5+
import { EscapeHtmlPipe } from '../../../../../../../shared/utils/escape-html.pipe';
56
import { RenderingTypeValueModelComponent } from '../rendering-type-value.model';
67

78
/**
@@ -13,7 +14,7 @@ import { RenderingTypeValueModelComponent } from '../rendering-type-value.model'
1314
templateUrl: './longtext.component.html',
1415
styleUrls: ['./longtext.component.scss'],
1516
standalone: true,
16-
imports: [TruncatableComponent, TruncatablePartComponent],
17+
imports: [TruncatableComponent, TruncatablePartComponent, EscapeHtmlPipe],
1718
})
1819
export class LongtextComponent extends RenderingTypeValueModelComponent {
1920

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<div [class]="field.styleValue">
2-
<span class="text-value" [attr.lang]="metadataValue.language" [innerHTML]="formatText(metadataValue.value)"></span>
2+
<span class="text-value" [attr.lang]="metadataValue.language" [innerHTML]="metadataValue.value | dsEscapeHtml"></span>
33
</div>

src/app/cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/text/text.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component } from '@angular/core';
22

3+
import { EscapeHtmlPipe } from '../../../../../../../shared/utils/escape-html.pipe';
34
import { RenderingTypeValueModelComponent } from '../rendering-type-value.model';
45

56
/**
@@ -11,6 +12,9 @@ import { RenderingTypeValueModelComponent } from '../rendering-type-value.model'
1112
templateUrl: './text.component.html',
1213
styleUrls: ['./text.component.scss'],
1314
standalone: true,
15+
imports: [
16+
EscapeHtmlPipe,
17+
],
1418
})
1519
export class TextComponent extends RenderingTypeValueModelComponent {
1620

src/app/shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<ds-badges *ngIf="showLabel" [object]="item" [context]="badgeContext" [showAccessStatus]="true"></ds-badges>
1010
</div>
1111
<ds-truncatable [id]="item.id">
12-
<h2 [innerHTML]="dsoTitle" [ngClass]="{'lead': true,'text-muted': !item.firstMetadataValue('dc.title')}"></h2>
12+
<h2 [innerHTML]="dsoTitle | dsEscapeHtml" [ngClass]="{'lead': true,'text-muted': !item.firstMetadataValue('dc.title')}"></h2>
1313
<ds-in-workflow-statistics *ngIf="showWorkflowStatistics" [item]="item" ></ds-in-workflow-statistics>
1414
<div>
1515
<span class="text-muted">

src/app/shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { SearchResult } from '../../../search/models/search-result.model';
3535
import { TruncatableComponent } from '../../../truncatable/truncatable.component';
3636
import { TruncatableService } from '../../../truncatable/truncatable.service';
3737
import { TruncatablePartComponent } from '../../../truncatable/truncatable-part/truncatable-part.component';
38+
import { EscapeHtmlPipe } from '../../../utils/escape-html.pipe';
3839
import { AdditionalMetadataComponent } from '../../search-result-list-element/additional-metadata/additional-metadata.component';
3940

4041
/**
@@ -62,6 +63,7 @@ import { AdditionalMetadataComponent } from '../../search-result-list-element/ad
6263
AdditionalMetadataComponent,
6364
ItemCorrectionComponent,
6465
InWorkflowStatisticsComponent,
66+
EscapeHtmlPipe,
6567
],
6668
})
6769
export class ItemListPreviewComponent implements OnInit {

src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
<ds-truncatable [id]="dso.id" *ngIf="object !== undefined && object !== null">
2424
<a *ngIf="linkType !== linkTypes.None" [target]="(linkType === linkTypes.ExternalLink) ? '_blank' : '_self'" [attr.rel]="(linkType === linkTypes.ExternalLink) ? 'noopener noreferrer' : null"
2525
[routerLink]="[itemPageRoute]" class="lead item-list-title dont-break-out"
26-
[innerHTML]="dsoTitle" role="link" tabindex="0"></a>
26+
[innerHTML]="dsoTitle | dsEscapeHtml" role="link" tabindex="0"></a>
2727
<span *ngIf="linkType === linkTypes.None" class="lead item-list-title dont-break-out"
28-
[innerHTML]="dsoTitle"></span>
28+
[innerHTML]="dsoTitle | dsEscapeHtml"></span>
2929
<ds-in-workflow-statistics *ngIf="showWorkflowStatistics" [item]="dso"></ds-in-workflow-statistics>
3030
<span class="text-muted">
3131
<ds-truncatable-part [id]="dso.id" [minLines]="1">

src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ describe('ItemSearchResultListElementComponent', () => {
400400

401401
it('should show highlighted title', () => {
402402
const titleField = fixture.debugElement.query(By.css('.item-list-title'));
403-
expect(titleField.nativeNode.innerHTML).toEqual(dcTitle);
403+
expect(titleField.nativeNode.innerHTML).toEqual('This is just another &lt;em&gt;title&lt;/em&gt;');
404404
});
405405
});
406406

@@ -412,7 +412,7 @@ describe('ItemSearchResultListElementComponent', () => {
412412

413413
it('should show highlighted title', () => {
414414
const titleField = fixture.debugElement.query(By.css('.item-list-title'));
415-
expect(titleField.nativeNode.innerHTML).toEqual('<em>Michel</em>');
415+
expect(titleField.nativeNode.innerHTML).toEqual('&lt;em&gt;Michel&lt;/em&gt;');
416416
});
417417
});
418418

@@ -424,7 +424,7 @@ describe('ItemSearchResultListElementComponent', () => {
424424

425425
it('should show highlighted title', () => {
426426
const titleField = fixture.debugElement.query(By.css('.item-list-title'));
427-
expect(titleField.nativeNode.innerHTML).toEqual('<em>Science</em>');
427+
expect(titleField.nativeNode.innerHTML).toEqual('&lt;em&gt;Science&lt;/em&gt;');
428428
});
429429
});
430430

0 commit comments

Comments
 (0)