mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-02-11 23:59:31 -06:00
Security: remove safe html pipe
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
import { TestBed } from '@angular/core/testing'
|
||||
import { BrowserModule, DomSanitizer } from '@angular/platform-browser'
|
||||
import { SafeHtmlPipe } from './safehtml.pipe'
|
||||
|
||||
describe('SafeHtmlPipe', () => {
|
||||
let pipe: SafeHtmlPipe
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [SafeHtmlPipe],
|
||||
imports: [BrowserModule],
|
||||
})
|
||||
pipe = TestBed.inject(SafeHtmlPipe)
|
||||
})
|
||||
|
||||
it('should bypass security and trust the url', () => {
|
||||
const html = '<div>some content</div>'
|
||||
const domSanitizer = TestBed.inject(DomSanitizer)
|
||||
const sanitizerSpy = jest.spyOn(domSanitizer, 'bypassSecurityTrustHtml')
|
||||
let safeHtml = pipe.transform(html)
|
||||
expect(safeHtml).not.toBeNull()
|
||||
expect(sanitizerSpy).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
@@ -1,13 +0,0 @@
|
||||
import { Pipe, PipeTransform, inject } from '@angular/core'
|
||||
import { DomSanitizer } from '@angular/platform-browser'
|
||||
|
||||
@Pipe({
|
||||
name: 'safeHtml',
|
||||
})
|
||||
export class SafeHtmlPipe implements PipeTransform {
|
||||
private sanitizer = inject(DomSanitizer)
|
||||
|
||||
transform(html) {
|
||||
return this.sanitizer.bypassSecurityTrustHtml(html)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user