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 { AppRoutingModule } from './app-routing.module';
import { TestmessengerComponent } from './testmessenger/testmessenger.component'; import { TestmessengerComponent } from './testmessenger/testmessenger.component';
import { DeploymentNotificationService } from './services/deployment-notification.service'; 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 { ConsoleComponent } from './console/console.component';
import { MonacoEditorModule } from 'ngx-monaco-editor'; import { MonacoEditorModule } from 'ngx-monaco-editor';
import { import {
@ -41,6 +41,7 @@ import { LoaderComponent } from './loader/loader.component';
DashboardComponent, DashboardComponent,
TestmessengerComponent, TestmessengerComponent,
SafePipe, SafePipe,
SafeHtmlPipe,
ConsoleComponent, ConsoleComponent,
LoaderComponent LoaderComponent
], ],

View File

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

View File

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