fix critical and high severity security vulnerabilities (#3060)
This commit is contained in:
+1
-1
@@ -670,7 +670,7 @@
|
||||
</div>
|
||||
<div class="description-body">
|
||||
<div #descriptionContent [ngClass]="{ 'line-clamp-7': !isExpanded }" class="description-content">
|
||||
<div class="description-html" [innerHTML]="book.metadata!.description"></div>
|
||||
<div class="description-html" [innerHTML]="sanitizeDescription(book.metadata!.description)"></div>
|
||||
</div>
|
||||
@if (isExpanded || isOverflowing) {
|
||||
<button class="expand-toggle" (click)="toggleExpand()">
|
||||
|
||||
+5
@@ -38,6 +38,7 @@ import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/tran
|
||||
import {AuthorService} from '../../../../author-browser/service/author.service';
|
||||
import {Dialog} from 'primeng/dialog';
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import DOMPurify from 'dompurify';
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -490,6 +491,10 @@ export class MetadataViewerComponent implements OnInit, OnChanges, AfterViewChec
|
||||
this.isExpanded = !this.isExpanded;
|
||||
}
|
||||
|
||||
sanitizeDescription(html: string | null | undefined): string {
|
||||
return html ? DOMPurify.sanitize(html) : '';
|
||||
}
|
||||
|
||||
read(bookId: number | undefined, reader?: "epub-streaming", bookType?: BookType): void {
|
||||
if (bookId) this.bookService.readBook(bookId, reader, bookType);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {IconService} from '../../services/icon.service';
|
||||
import {IconCacheService} from '../../services/icon-cache.service';
|
||||
import {DomSanitizer, SafeHtml} from '@angular/platform-browser';
|
||||
import DOMPurify from 'dompurify';
|
||||
import {UrlHelperService} from '../../service/url-helper.service';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {IconCategoriesHelper} from '../../helpers/icon-categories.helper';
|
||||
@@ -158,7 +159,11 @@ export class IconPickerComponent implements OnInit {
|
||||
}
|
||||
|
||||
try {
|
||||
this.svgPreview = this.sanitizer.bypassSecurityTrustHtml(this.svgContent);
|
||||
const sanitized = DOMPurify.sanitize(this.svgContent, {
|
||||
USE_PROFILES: { svg: true },
|
||||
FORBID_TAGS: ['script', 'style', 'foreignObject']
|
||||
});
|
||||
this.svgPreview = this.sanitizer.bypassSecurityTrustHtml(sanitized);
|
||||
} catch {
|
||||
this.svgPreview = null;
|
||||
this.errorMessage = this.ERROR_MESSAGES.PARSE_ERROR;
|
||||
|
||||
+3
-4
@@ -1,8 +1,8 @@
|
||||
import { Component, inject, OnInit } from '@angular/core';
|
||||
import { ReleaseNote, VersionService } from '../../../../service/version.service';
|
||||
|
||||
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
|
||||
import showdown from 'showdown';
|
||||
import DOMPurify from 'dompurify';
|
||||
import {DatePipe} from '@angular/common';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {Button} from 'primeng/button';
|
||||
@@ -22,7 +22,6 @@ import {TranslocoDirective} from '@jsverse/transloco';
|
||||
export class VersionChangelogDialogComponent implements OnInit {
|
||||
|
||||
private versionService = inject(VersionService);
|
||||
private sanitizer = inject(DomSanitizer);
|
||||
dialogRef = inject(DynamicDialogRef);
|
||||
|
||||
changelog: ReleaseNote[] = [];
|
||||
@@ -42,9 +41,9 @@ export class VersionChangelogDialogComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
markdownToHtml(markdown: string): SafeHtml {
|
||||
markdownToHtml(markdown: string): string {
|
||||
let html = this.converter.makeHtml(markdown);
|
||||
html = html.replace(/<h2\b([^>]*)>/g, '<h3$1>').replace(/<\/h2>/g, '</h3>');
|
||||
return this.sanitizer.bypassSecurityTrustHtml(html);
|
||||
return DOMPurify.sanitize(html);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user