Stop filtering JS code in bot messages

This commit is contained in:
R. Richard 2020-05-18 18:01:17 +02:00
parent 031a9916a0
commit d8545c48be
3 changed files with 14 additions and 2 deletions

View File

@ -17,7 +17,7 @@ import { TerminalComponent } from './terminal/terminal.component';
import { AppRoutingModule } from './app-routing.module';
import { TestmessengerComponent } from './testmessenger/testmessenger.component';
import { DeploymentNotificationService } from './services/deployment-notification.service';
import { SafePipe } from './pipes/safe.pipe';
import { SafePipe, SafeHtmlPipe } from './pipes/safe.pipe';
import { ConsoleComponent } from './console/console.component';
import { MonacoEditorModule } from 'ngx-monaco-editor';
import {
@ -41,6 +41,7 @@ import { LoaderComponent } from './loader/loader.component';
DashboardComponent,
TestmessengerComponent,
SafePipe,
SafeHtmlPipe,
ConsoleComponent,
LoaderComponent
],

View File

@ -8,7 +8,7 @@
<div class="tao-grid-center-left originator">{{message.originator}}</div>
<div class="timestamp tao-grid-center-right">{{message.timestamp | date:'HH:mm:ss'}}</div>
</div>
<div class="tfw-grid-message-body" [innerHtml]="message.message"></div>
<div class="tfw-grid-message-body" [innerHtml]="message.message | safeHtml"></div>
</div>
<div *ngIf="showTypingIndicator"
class="tfw-grid-message jumping-circle-container"

View File

@ -11,3 +11,14 @@ export class SafePipe implements PipeTransform {
return this.sanitizer.bypassSecurityTrustResourceUrl(value);
}
}
@Pipe({
name: 'safeHtml'
})
export class SafeHtmlPipe implements PipeTransform {
constructor(private sanitized: DomSanitizer) {}
transform(value) {
return this.sanitized.bypassSecurityTrustHtml(value);
}
}