Skip to content

Commit

Permalink
Fix markdown blockquote preview difference (#1245)
Browse files Browse the repository at this point in the history
Due to DOMPurify, the content used for preview is different.
However, given that ngx-markdown already has sufficient sanitation
by default, we remove sanitation by DOMPurify.
  • Loading branch information
nknguyenhc authored Feb 21, 2024
1 parent e319865 commit 944a424
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 8 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"arcsecond": "^4.1.0",
"core-js": "^3.16.4",
"diff-match-patch": "^1.0.4",
"dompurify": "^2.3.1",
"graphql": "^15.0.0",
"karma-spec-reporter": "0.0.32",
"moment": "^2.24.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</mat-tab>
<mat-tab label="Preview">
<div class="tab-content" style="min-height: 228px">
<markdown #markdownArea *ngIf="commentField.value !== ''" [data]="sanitize(commentField.value)" disableInternalLink></markdown>
<markdown #markdownArea *ngIf="commentField.value !== ''" [data]="commentField.value" disableInternalLink></markdown>
<div *ngIf="commentField.value === ''">Nothing to preview.</div>
</div>
</mat-tab>
Expand Down
6 changes: 0 additions & 6 deletions src/app/shared/comment-editor/comment-editor.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { HttpErrorResponse } from '@angular/common/http';
import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
import { AbstractControl, FormGroup, Validators } from '@angular/forms';
import * as DOMPurify from 'dompurify';
import { UndoRedo } from '../../core/models/undoredo.model';
import { ErrorHandlingService } from '../../core/services/error-handling.service';
import { LoggingService } from '../../core/services/logging.service';
Expand Down Expand Up @@ -135,11 +134,6 @@ export class CommentEditorComponent implements OnInit {
event.preventDefault();
}

// Sanitize markdown
sanitize(commentFieldValue) {
return DOMPurify.sanitize(commentFieldValue);
}

// To enable file drop in non-input elements, the dragOver event must be cancelled.
enableFileDrop(event) {
event.preventDefault();
Expand Down

0 comments on commit 944a424

Please sign in to comment.