Skip to content

Commit

Permalink
First attempt at sanitising the collection content field HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
alexklbuckley committed Oct 2, 2024
1 parent 12d1488 commit 10b7337
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
</ds-comcol-page-header>
<!-- header text -->
<ds-comcol-page-content
[content]="collection.customHeaderText"
[hasInnerHtml]="true">
[innerHTML]="sanitizeCustomHeaderText(collection.customHeaderText)">
</ds-comcol-page-content>
<!-- intro text -->
<ds-comcol-page-content
[content]="collection.customHomePageIntroText"
[hasInnerHtml]="true">
[innerHTML]="sanitizeCustomIntrotext(collection.customHomePageIntroText)">
</ds-comcol-page-content>
<!-- Collection logo -->
<ds-comcol-page-logo *ngIf="logoRD$"
Expand Down Expand Up @@ -46,13 +44,11 @@
<footer *ngIf="(collection.copyrightText || collection.customOwnerNameText || collection.customFooterText)" class="border-top my-5 pt-4">
<!-- owner name -->
<ds-comcol-page-content
[content]="collection.customOwnerNameText"
[hasInnerHtml]="true">
[innerHTML]="sanitizeOwnerNameText(collection.customOwnerNameText)">
</ds-comcol-page-content>
<!-- footer -->
<ds-comcol-page-content
[content]="collection.customFooterText"
[hasInnerHtml]="true">
[innerHTML]="sanitizeCustomFootertext(collection.customFooterText)">
</ds-comcol-page-content>
<!-- Copyright -->
<ds-comcol-page-content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import {
ChangeDetectionStrategy,
Component,
OnInit,
SecurityContext,
} from '@angular/core';
import {

Check failure on line 11 in src/app/collection-page/collection-home/collection-home-page.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Imports must not be broken into multiple lines if there are 1 or less elements

Check failure on line 11 in src/app/collection-page/collection-home/collection-home-page.component.ts

View workflow job for this annotation

GitHub Actions / tests (20.x)

Imports must not be broken into multiple lines if there are 1 or less elements
DomSanitizer,
} from '@angular/platform-browser';
import {
ActivatedRoute,
Router,
Expand Down Expand Up @@ -103,6 +107,7 @@ export class CollectionHomePageComponent implements OnInit {
protected authService: AuthService,
protected authorizationDataService: AuthorizationDataService,
public dsoNameService: DSONameService,
protected sanitizer: DomSanitizer,
) {
}

Expand All @@ -129,5 +134,16 @@ export class CollectionHomePageComponent implements OnInit {
return isNotEmpty(object);
}


public sanitizeCustomHeaderText(value) {
return this.sanitizer.sanitize(SecurityContext.HTML, value);
}
public sanitizeCustomIntrotext(value) {
return this.sanitizer.sanitize(SecurityContext.HTML, value);
}
public sanitizeOwnerNameText(value) {
return this.sanitizer.sanitize(SecurityContext.HTML, value);
}
public sanitizeCustomFootertext(value) {
return this.sanitizer.sanitize(SecurityContext.HTML, value);
}
}

0 comments on commit 10b7337

Please sign in to comment.