aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-forms
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-09-08 10:10:51 +0200
committerChocobozzz <me@florianbigard.com>2021-09-08 10:16:39 +0200
commit0ea2f79d45b301fcd660efc894469a99b2239bf6 (patch)
treef100945f86cdcac37cf953b5af0c8fd1a3c8daad /client/src/app/shared/shared-forms
parent4546d92e40a253047d9648c0749578429dce1c3f (diff)
downloadPeerTube-0ea2f79d45b301fcd660efc894469a99b2239bf6.tar.gz
PeerTube-0ea2f79d45b301fcd660efc894469a99b2239bf6.tar.zst
PeerTube-0ea2f79d45b301fcd660efc894469a99b2239bf6.zip
Safer image preview
Diffstat (limited to 'client/src/app/shared/shared-forms')
-rw-r--r--client/src/app/shared/shared-forms/preview-upload.component.ts8
1 files changed, 3 insertions, 5 deletions
diff --git a/client/src/app/shared/shared-forms/preview-upload.component.ts b/client/src/app/shared/shared-forms/preview-upload.component.ts
index edee6786d..a857b0a4f 100644
--- a/client/src/app/shared/shared-forms/preview-upload.component.ts
+++ b/client/src/app/shared/shared-forms/preview-upload.component.ts
@@ -1,7 +1,7 @@
1import { Component, forwardRef, Input, OnInit } from '@angular/core' 1import { Component, forwardRef, Input, OnInit } from '@angular/core'
2import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' 2import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
3import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'
4import { ServerService } from '@app/core' 3import { ServerService } from '@app/core'
4import { imageToDataURL } from '@root-helpers/images'
5import { HTMLServerConfig } from '@shared/models' 5import { HTMLServerConfig } from '@shared/models'
6import { BytesPipe } from '../shared-main' 6import { BytesPipe } from '../shared-main'
7 7
@@ -23,7 +23,7 @@ export class PreviewUploadComponent implements OnInit, ControlValueAccessor {
23 @Input() previewWidth: string 23 @Input() previewWidth: string
24 @Input() previewHeight: string 24 @Input() previewHeight: string
25 25
26 imageSrc: SafeResourceUrl 26 imageSrc: string
27 allowedExtensionsMessage = '' 27 allowedExtensionsMessage = ''
28 maxSizeText: string 28 maxSizeText: string
29 29
@@ -32,7 +32,6 @@ export class PreviewUploadComponent implements OnInit, ControlValueAccessor {
32 private file: Blob 32 private file: Blob
33 33
34 constructor ( 34 constructor (
35 private sanitizer: DomSanitizer,
36 private serverService: ServerService 35 private serverService: ServerService
37 ) { 36 ) {
38 this.bytesPipe = new BytesPipe() 37 this.bytesPipe = new BytesPipe()
@@ -81,8 +80,7 @@ export class PreviewUploadComponent implements OnInit, ControlValueAccessor {
81 80
82 private updatePreview () { 81 private updatePreview () {
83 if (this.file) { 82 if (this.file) {
84 const url = URL.createObjectURL(this.file) 83 imageToDataURL(this.file).then(result => this.imageSrc = result)
85 this.imageSrc = this.sanitizer.bypassSecurityTrustResourceUrl(url)
86 } 84 }
87 } 85 }
88} 86}