diff options
author | Chocobozzz <me@florianbigard.com> | 2021-09-08 10:10:51 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-09-08 10:16:39 +0200 |
commit | 0ea2f79d45b301fcd660efc894469a99b2239bf6 (patch) | |
tree | f100945f86cdcac37cf953b5af0c8fd1a3c8daad /client/src/app/shared/shared-actor-image-edit | |
parent | 4546d92e40a253047d9648c0749578429dce1c3f (diff) | |
download | PeerTube-0ea2f79d45b301fcd660efc894469a99b2239bf6.tar.gz PeerTube-0ea2f79d45b301fcd660efc894469a99b2239bf6.tar.zst PeerTube-0ea2f79d45b301fcd660efc894469a99b2239bf6.zip |
Safer image preview
Diffstat (limited to 'client/src/app/shared/shared-actor-image-edit')
-rw-r--r-- | client/src/app/shared/shared-actor-image-edit/actor-avatar-edit.component.ts | 7 | ||||
-rw-r--r-- | client/src/app/shared/shared-actor-image-edit/actor-banner-edit.component.ts | 6 |
2 files changed, 6 insertions, 7 deletions
diff --git a/client/src/app/shared/shared-actor-image-edit/actor-avatar-edit.component.ts b/client/src/app/shared/shared-actor-image-edit/actor-avatar-edit.component.ts index 2c0e45e20..8b7d64ed3 100644 --- a/client/src/app/shared/shared-actor-image-edit/actor-avatar-edit.component.ts +++ b/client/src/app/shared/shared-actor-image-edit/actor-avatar-edit.component.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' |
2 | import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser' | ||
3 | import { Notifier, ServerService } from '@app/core' | 2 | import { Notifier, ServerService } from '@app/core' |
4 | import { Account, VideoChannel } from '@app/shared/shared-main' | 3 | import { Account, VideoChannel } from '@app/shared/shared-main' |
5 | import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' | 4 | import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' |
6 | import { getBytes } from '@root-helpers/bytes' | 5 | import { getBytes } from '@root-helpers/bytes' |
6 | import { imageToDataURL } from '@root-helpers/images' | ||
7 | 7 | ||
8 | @Component({ | 8 | @Component({ |
9 | selector: 'my-actor-avatar-edit', | 9 | selector: 'my-actor-avatar-edit', |
@@ -30,10 +30,9 @@ export class ActorAvatarEditComponent implements OnInit { | |||
30 | maxAvatarSize = 0 | 30 | maxAvatarSize = 0 |
31 | avatarExtensions = '' | 31 | avatarExtensions = '' |
32 | 32 | ||
33 | preview: SafeResourceUrl | 33 | preview: string |
34 | 34 | ||
35 | constructor ( | 35 | constructor ( |
36 | private sanitizer: DomSanitizer, | ||
37 | private serverService: ServerService, | 36 | private serverService: ServerService, |
38 | private notifier: Notifier | 37 | private notifier: Notifier |
39 | ) { } | 38 | ) { } |
@@ -63,7 +62,7 @@ export class ActorAvatarEditComponent implements OnInit { | |||
63 | this.avatarChange.emit(formData) | 62 | this.avatarChange.emit(formData) |
64 | 63 | ||
65 | if (this.previewImage) { | 64 | if (this.previewImage) { |
66 | this.preview = this.sanitizer.bypassSecurityTrustResourceUrl(URL.createObjectURL(avatarfile)) | 65 | imageToDataURL(avatarfile).then(result => this.preview = result) |
67 | } | 66 | } |
68 | } | 67 | } |
69 | 68 | ||
diff --git a/client/src/app/shared/shared-actor-image-edit/actor-banner-edit.component.ts b/client/src/app/shared/shared-actor-image-edit/actor-banner-edit.component.ts index cba2c5db3..47b537b74 100644 --- a/client/src/app/shared/shared-actor-image-edit/actor-banner-edit.component.ts +++ b/client/src/app/shared/shared-actor-image-edit/actor-banner-edit.component.ts | |||
@@ -1,9 +1,10 @@ | |||
1 | import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' |
2 | import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser' | 2 | import { SafeResourceUrl } from '@angular/platform-browser' |
3 | import { Notifier, ServerService } from '@app/core' | 3 | import { Notifier, ServerService } from '@app/core' |
4 | import { VideoChannel } from '@app/shared/shared-main' | 4 | import { VideoChannel } from '@app/shared/shared-main' |
5 | import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' | 5 | import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' |
6 | import { getBytes } from '@root-helpers/bytes' | 6 | import { getBytes } from '@root-helpers/bytes' |
7 | import { imageToDataURL } from '@root-helpers/images' | ||
7 | 8 | ||
8 | @Component({ | 9 | @Component({ |
9 | selector: 'my-actor-banner-edit', | 10 | selector: 'my-actor-banner-edit', |
@@ -30,7 +31,6 @@ export class ActorBannerEditComponent implements OnInit { | |||
30 | preview: SafeResourceUrl | 31 | preview: SafeResourceUrl |
31 | 32 | ||
32 | constructor ( | 33 | constructor ( |
33 | private sanitizer: DomSanitizer, | ||
34 | private serverService: ServerService, | 34 | private serverService: ServerService, |
35 | private notifier: Notifier | 35 | private notifier: Notifier |
36 | ) { } | 36 | ) { } |
@@ -59,7 +59,7 @@ export class ActorBannerEditComponent implements OnInit { | |||
59 | this.bannerChange.emit(formData) | 59 | this.bannerChange.emit(formData) |
60 | 60 | ||
61 | if (this.previewImage) { | 61 | if (this.previewImage) { |
62 | this.preview = this.sanitizer.bypassSecurityTrustResourceUrl(URL.createObjectURL(bannerfile)) | 62 | imageToDataURL(bannerfile).then(result => this.preview = result) |
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||