diff --git a/client/src/app/core/repositories/motions/motion-repository.service.ts b/client/src/app/core/repositories/motions/motion-repository.service.ts index fcf656c4d..522db0ad9 100644 --- a/client/src/app/core/repositories/motions/motion-repository.service.ts +++ b/client/src/app/core/repositories/motions/motion-repository.service.ts @@ -1,5 +1,4 @@ import { Injectable } from '@angular/core'; -import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; import { TranslateService } from '@ngx-translate/core'; import { Observable } from 'rxjs'; @@ -51,12 +50,7 @@ export interface ParagraphToChoose { /** * The raw HTML of this paragraph. */ - rawHtml: string; - - /** - * The HTML of this paragraph, wrapped in a `SafeHtml`-object. - */ - safeHtml: SafeHtml; + html: string; /** * The first line number @@ -186,7 +180,6 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo * @param mapperService Maps collection strings to classes * @param dataSend sending changed objects * @param httpService OpenSlides own Http service - * @param sanitizer DOM Sanitizer * @param lineNumbering Line numbering for motion text * @param diff Display changes in motion text as diff. * @param personalNoteService service fo personal notes @@ -201,7 +194,6 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo relationManager: RelationManagerService, config: ConfigService, private httpService: HttpService, - private readonly sanitizer: DomSanitizer, private readonly lineNumbering: LinenumberingService, private readonly diff: DiffService, private operator: OperatorService @@ -713,8 +705,7 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo const affected: LineNumberRange = this.lineNumbering.getLineNumberRange(paragraph); return { paragraphNo: index, - safeHtml: this.sanitizer.bypassSecurityTrustHtml(paragraph), - rawHtml: this.lineNumbering.stripLineNumbers(paragraph), + html: this.lineNumbering.stripLineNumbers(paragraph), lineFrom: affected.from, lineTo: affected.to }; diff --git a/client/src/app/shared/components/legal-notice-content/legal-notice-content.component.html b/client/src/app/shared/components/legal-notice-content/legal-notice-content.component.html index 1820b667b..5c3f1caf1 100644 --- a/client/src/app/shared/components/legal-notice-content/legal-notice-content.component.html +++ b/client/src/app/shared/components/legal-notice-content/legal-notice-content.component.html @@ -1,6 +1,6 @@
- +
The event manager hasn't set up a legal notice yet.
diff --git a/client/src/app/shared/components/preview/preview.component.html b/client/src/app/shared/components/preview/preview.component.html index 4a8283546..1bcddd88c 100644 --- a/client/src/app/shared/components/preview/preview.component.html +++ b/client/src/app/shared/components/preview/preview.component.html @@ -27,13 +27,13 @@
{{ entry.key | translate }}
{{ entry.value }}
-
+
{{ property.key | translate }}
{{ property.value }}
-
+
diff --git a/client/src/app/shared/components/preview/preview.component.ts b/client/src/app/shared/components/preview/preview.component.ts index 431ee8053..3a53a9c5e 100644 --- a/client/src/app/shared/components/preview/preview.component.ts +++ b/client/src/app/shared/components/preview/preview.component.ts @@ -1,5 +1,4 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnDestroy } from '@angular/core'; -import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; import { SearchProperty } from 'app/core/ui-services/search.service'; import { BaseViewModel } from 'app/site/base/base-view-model'; @@ -45,10 +44,8 @@ export class PreviewComponent implements OnDestroy { /** * Default constructor - * - * @param sanitizer DomSanitizer */ - public constructor(private sanitizer: DomSanitizer, private cd: ChangeDetectorRef) {} + public constructor(private cd: ChangeDetectorRef) {} /** * detach the change detection @@ -56,15 +53,4 @@ export class PreviewComponent implements OnDestroy { public ngOnDestroy(): void { this.cd.detach(); } - - /** - * Function to sanitize any text to show html. - * - * @param text The text to sanitize. - * - * @returns {SafeHtml} The sanitized text as `HTML`. - */ - public sanitize(text: string): SafeHtml { - return this.sanitizer.bypassSecurityTrustHtml(text); - } } diff --git a/client/src/app/shared/components/privacy-policy-content/privacy-policy-content.component.html b/client/src/app/shared/components/privacy-policy-content/privacy-policy-content.component.html index 1d14ae5ee..4e1f94960 100644 --- a/client/src/app/shared/components/privacy-policy-content/privacy-policy-content.component.html +++ b/client/src/app/shared/components/privacy-policy-content/privacy-policy-content.component.html @@ -1,5 +1,5 @@ -
+
The event manager hasn't set up a privacy policy yet.
diff --git a/client/src/app/shared/pipes/trust.pipe.spec.ts b/client/src/app/shared/pipes/trust.pipe.spec.ts new file mode 100644 index 000000000..725e2d56c --- /dev/null +++ b/client/src/app/shared/pipes/trust.pipe.spec.ts @@ -0,0 +1,11 @@ +import { inject } from '@angular/core/testing'; +import { DomSanitizer } from '@angular/platform-browser'; + +import { TrustPipe } from './trust.pipe'; + +describe('TrustHtmlPipe', () => { + it('create an instance', inject([DomSanitizer], (domSanitizer: DomSanitizer) => { + const pipe = new TrustPipe(domSanitizer); + expect(pipe).toBeTruthy(); + })); +}); diff --git a/client/src/app/shared/pipes/trust.pipe.ts b/client/src/app/shared/pipes/trust.pipe.ts new file mode 100644 index 000000000..9a2ece256 --- /dev/null +++ b/client/src/app/shared/pipes/trust.pipe.ts @@ -0,0 +1,29 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import { DomSanitizer, SafeHtml, SafeResourceUrl, SafeScript, SafeStyle, SafeUrl } from '@angular/platform-browser'; + +/** + * Pipe to use bypassSecurityTrust + */ +@Pipe({ + name: 'trust' +}) +export class TrustPipe implements PipeTransform { + public constructor(protected sanitizer: DomSanitizer) {} + + public transform(value: any, type: string): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl { + switch (type) { + case 'html': + return this.sanitizer.bypassSecurityTrustHtml(value); + case 'style': + return this.sanitizer.bypassSecurityTrustStyle(value); + case 'script': + return this.sanitizer.bypassSecurityTrustScript(value); + case 'url': + return this.sanitizer.bypassSecurityTrustUrl(value); + case 'resourceUrl': + return this.sanitizer.bypassSecurityTrustResourceUrl(value); + default: + throw new Error(`Invalid safe type specified: ${type}`); + } + } +} diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts index 767b59cb7..4d0d5930d 100644 --- a/client/src/app/shared/shared.module.ts +++ b/client/src/app/shared/shared.module.ts @@ -107,6 +107,7 @@ import { PreviewComponent } from './components/preview/preview.component'; import { PdfViewerModule } from 'ng2-pdf-viewer'; import { GlobalSpinnerComponent } from 'app/site/common/components/global-spinner/global-spinner.component'; import { HeightResizingDirective } from './directives/height-resizing.directive'; +import { TrustPipe } from './pipes/trust.pipe'; /** * Share Module for all "dumb" components and pipes. @@ -254,7 +255,8 @@ import { HeightResizingDirective } from './directives/height-resizing.directive' GlobalSpinnerComponent, OverlayComponent, PreviewComponent, - NgxMaterialTimepickerModule + NgxMaterialTimepickerModule, + TrustPipe ], declarations: [ PermsDirective, @@ -299,7 +301,8 @@ import { HeightResizingDirective } from './directives/height-resizing.directive' SuperSearchComponent, OverlayComponent, PreviewComponent, - HeightResizingDirective + HeightResizingDirective, + TrustPipe ], providers: [ { @@ -313,7 +316,8 @@ import { HeightResizingDirective } from './directives/height-resizing.directive' SortFilterBarComponent, SortBottomSheetComponent, DecimalPipe, - ProgressSnackBarComponent + ProgressSnackBarComponent, + TrustPipe ], entryComponents: [ SortBottomSheetComponent, diff --git a/client/src/app/site/assignments/components/assignment-detail/assignment-detail.component.html b/client/src/app/site/assignments/components/assignment-detail/assignment-detail.component.html index 58451f916..3b905eb72 100644 --- a/client/src/app/site/assignments/components/assignment-detail/assignment-detail.component.html +++ b/client/src/app/site/assignments/components/assignment-detail/assignment-detail.component.html @@ -76,7 +76,7 @@
diff --git a/client/src/app/site/assignments/components/assignment-detail/assignment-detail.component.ts b/client/src/app/site/assignments/components/assignment-detail/assignment-detail.component.ts index 05226c494..f584de7c9 100644 --- a/client/src/app/site/assignments/components/assignment-detail/assignment-detail.component.ts +++ b/client/src/app/site/assignments/components/assignment-detail/assignment-detail.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { MatSnackBar } from '@angular/material'; -import { DomSanitizer, SafeHtml, Title } from '@angular/platform-browser'; +import { Title } from '@angular/platform-browser'; import { ActivatedRoute, Router } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; @@ -181,8 +181,7 @@ export class AssignmentDetailComponent extends BaseViewComponent implements OnIn private tagRepo: TagRepositoryService, private promptService: PromptService, private pdfService: AssignmentPdfExportService, - private mediafileRepo: MediafileRepositoryService, - private sanitizer: DomSanitizer + private mediafileRepo: MediafileRepositoryService ) { super(title, translate, matSnackBar); this.subscriptions.push( @@ -503,17 +502,6 @@ export class AssignmentDetailComponent extends BaseViewComponent implements OnIn .then(null, this.raiseError); } - /** - * Sanitize the text. - * - * @param text {string} The text to display. - * - * @returns {SafeHtml} the sanitized text. - */ - public getSanitizedText(text: string): SafeHtml { - return this.sanitizer.bypassSecurityTrustHtml(text); - } - public addToAgenda(): void { this.itemRepo.addItemToAgenda(this.assignment).then(null, this.raiseError); } diff --git a/client/src/app/site/common/components/start/start.component.html b/client/src/app/site/common/components/start/start.component.html index 747e1daf3..64bfd33da 100644 --- a/client/src/app/site/common/components/start/start.component.html +++ b/client/src/app/site/common/components/start/start.component.html @@ -8,6 +8,6 @@

{{ welcomeTitle | translate }}

-
+
diff --git a/client/src/app/site/common/components/start/start.component.ts b/client/src/app/site/common/components/start/start.component.ts index 0048373de..3bb886706 100644 --- a/client/src/app/site/common/components/start/start.component.ts +++ b/client/src/app/site/common/components/start/start.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from '@angular/core'; -import { DomSanitizer, SafeHtml, Title } from '@angular/platform-browser'; +import { Title } from '@angular/platform-browser'; import { TranslateService } from '@ngx-translate/core'; // showcase @@ -16,7 +16,7 @@ import { ConfigService } from 'app/core/ui-services/config.service'; }) export class StartComponent extends BaseComponent implements OnInit { public welcomeTitle: string; - public welcomeText: SafeHtml; + public welcomeText: string; /** * Constructor of the StartComponent @@ -24,14 +24,8 @@ export class StartComponent extends BaseComponent implements OnInit { * @param titleService the title serve * @param translate to translation module * @param configService read out config values - * @param sanitizer */ - public constructor( - titleService: Title, - translate: TranslateService, - private configService: ConfigService, - private sanitizer: DomSanitizer - ) { + public constructor(titleService: Title, translate: TranslateService, private configService: ConfigService) { super(titleService, translate); } @@ -50,18 +44,7 @@ export class StartComponent extends BaseComponent implements OnInit { // set the welcome text this.configService.get('general_event_welcome_text').subscribe(welcomeText => { - this.welcomeText = this.sanitizeText(this.translate.instant(welcomeText)); + this.welcomeText = this.translate.instant(welcomeText); }); } - - /** - * Sanitizes the value from database. - * - * @param text The plain text to sanitize. - * - * @returns {SafeHtml} Html, that will be rendered with styles and so on... - */ - public sanitizeText(text: string): SafeHtml { - return this.sanitizer.bypassSecurityTrustHtml(text); - } } diff --git a/client/src/app/site/motions/modules/amendment-list/amendment-list.component.html b/client/src/app/site/motions/modules/amendment-list/amendment-list.component.html index 9f57ce990..c1181c414 100644 --- a/client/src/app/site/motions/modules/amendment-list/amendment-list.component.html +++ b/client/src/app/site/motions/modules/amendment-list/amendment-list.component.html @@ -84,7 +84,7 @@
-
+
diff --git a/client/src/app/site/motions/modules/amendment-list/amendment-list.component.ts b/client/src/app/site/motions/modules/amendment-list/amendment-list.component.ts index c1500c1e4..2f1eb10e4 100644 --- a/client/src/app/site/motions/modules/amendment-list/amendment-list.component.ts +++ b/client/src/app/site/motions/modules/amendment-list/amendment-list.component.ts @@ -1,6 +1,6 @@ import { ChangeDetectionStrategy, Component, OnInit, ViewEncapsulation } from '@angular/core'; import { MatDialog, MatSnackBar } from '@angular/material'; -import { DomSanitizer, SafeHtml, Title } from '@angular/platform-browser'; +import { Title } from '@angular/platform-browser'; import { ActivatedRoute, ParamMap } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; @@ -94,7 +94,6 @@ export class AmendmentListComponent extends BaseListViewComponent im public motionSortService: MotionSortListService, public amendmentSortService: AmendmentSortListService, public amendmentFilterService: AmendmentFilterListService, - private sanitizer: DomSanitizer, private dialog: MatDialog, private motionExport: MotionExportService, private linenumberingService: LinenumberingService, @@ -163,8 +162,4 @@ export class AmendmentListComponent extends BaseListViewComponent im const parentMotion = this.parentMotionId ? this.motionRepo.getViewModel(this.parentMotionId) : undefined; this.pdfExport.exportAmendmentList(this.dataSource.filteredData, parentMotion); } - - public sanitizeText(text: string): SafeHtml { - return this.sanitizer.bypassSecurityTrustHtml(text); - } } diff --git a/client/src/app/site/motions/modules/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.html b/client/src/app/site/motions/modules/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.html index 50e365df7..976577164 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.html +++ b/client/src/app/site/motions/modules/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.html @@ -12,7 +12,11 @@
-
@@ -48,7 +52,7 @@ [checked]="isParagraphSelected(paragraph)" > -
+
diff --git a/client/src/app/site/motions/modules/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.ts b/client/src/app/site/motions/modules/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.ts index fc4b0ee0f..ea418745c 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.ts +++ b/client/src/app/site/motions/modules/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.ts @@ -158,7 +158,7 @@ export class AmendmentCreateWizardComponent extends BaseViewComponent { }); this.contentForm.addControl( 'text_' + paragraph.paragraphNo, - new FormControl(paragraph.rawHtml, Validators.required) + new FormControl(paragraph.html, Validators.required) ); this.contentForm.patchValue({ selectedParagraphs: [paragraph] @@ -195,7 +195,7 @@ export class AmendmentCreateWizardComponent extends BaseViewComponent { this.contentForm.addControl( 'text_' + paragraph.paragraphNo, - new FormControl(paragraph.rawHtml, Validators.required) + new FormControl(paragraph.html, Validators.required) ); this.contentForm.patchValue({ selectedParagraphs: newParagraphs diff --git a/client/src/app/site/motions/modules/motion-detail/components/motion-comments/motion-comments.component.html b/client/src/app/site/motions/modules/motion-detail/components/motion-comments/motion-comments.component.html index dae7b7081..e26b162cc 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/motion-comments/motion-comments.component.html +++ b/client/src/app/site/motions/modules/motion-detail/components/motion-comments/motion-comments.component.html @@ -11,7 +11,7 @@ -
+
No comment
diff --git a/client/src/app/site/motions/modules/motion-detail/components/motion-comments/motion-comments.component.ts b/client/src/app/site/motions/modules/motion-detail/components/motion-comments/motion-comments.component.ts index 9e7062c64..347092d70 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/motion-comments/motion-comments.component.ts +++ b/client/src/app/site/motions/modules/motion-detail/components/motion-comments/motion-comments.component.ts @@ -1,7 +1,7 @@ import { Component, Input } from '@angular/core'; import { FormBuilder, FormGroup } from '@angular/forms'; import { MatSnackBar } from '@angular/material/snack-bar'; -import { DomSanitizer, SafeHtml, Title } from '@angular/platform-browser'; +import { Title } from '@angular/platform-browser'; import { TranslateService } from '@ngx-translate/core'; @@ -65,7 +65,6 @@ export class MotionCommentsComponent extends BaseViewComponent { * @param formBuilder Form builder to handle text editing * @param operator service to get the sections * @param pdfService service to export a comment section to pdf - * @param sanitizer to sanitize the inner html text * @param titleService set the browser title * @param translate the translation service * @param matSnackBar showing errors and information @@ -75,7 +74,6 @@ export class MotionCommentsComponent extends BaseViewComponent { private formBuilder: FormBuilder, private operator: OperatorService, private pdfService: MotionPdfExportService, - private sanitizer: DomSanitizer, titleService: Title, translate: TranslateService, matSnackBar: MatSnackBar @@ -189,15 +187,4 @@ export class MotionCommentsComponent extends BaseViewComponent { public pdfExportSection(section: ViewMotionCommentSection): void { this.pdfService.exportComment(section, this.motion); } - - /** - * Sanitize the text to be safe. - * - * @param text to be sanitized. - * - * @returns SafeHtml - */ - public sanitizeText(text: string): SafeHtml { - return this.sanitizer.bypassSecurityTrustHtml(text); - } } diff --git a/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.html b/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.html index 232883fd8..dd6a530f8 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.html +++ b/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.html @@ -67,7 +67,7 @@ [attr.data-change-id]="changedTitle.getChangeId()" >
{{ 'Changed title' | translate }}:
-
+
@@ -122,7 +122,7 @@ [class.line-numbers-inline]="isLineNumberingInline()" [class.line-numbers-outside]="isLineNumberingOutside()" [attr.data-change-id]="change.getChangeId()" - [innerHTML]="getDiff(change)" + [innerHTML]="getDiff(change) | trust: 'html'" > diff --git a/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.ts b/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.ts index 91f2889a7..9d2d9dc2a 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.ts +++ b/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.ts @@ -1,7 +1,7 @@ import { AfterViewInit, Component, ElementRef, EventEmitter, Input, Output } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { MatSnackBar } from '@angular/material/snack-bar'; -import { DomSanitizer, SafeHtml, Title } from '@angular/platform-browser'; +import { Title } from '@angular/platform-browser'; import { TranslateService } from '@ngx-translate/core'; @@ -81,7 +81,6 @@ export class MotionDetailDiffComponent extends BaseViewComponent implements Afte * @param title * @param translate * @param matSnackBar - * @param sanitizer * @param diff * @param recoRepo * @param dialogService @@ -93,7 +92,6 @@ export class MotionDetailDiffComponent extends BaseViewComponent implements Afte title: Title, protected translate: TranslateService, // protected required for ng-translate-extract matSnackBar: MatSnackBar, - private sanitizer: DomSanitizer, private diff: DiffService, private recoRepo: ChangeRecommendationRepositoryService, private dialogService: MatDialog, @@ -157,9 +155,8 @@ export class MotionDetailDiffComponent extends BaseViewComponent implements Afte * Returns the diff string from the motion to the change * @param {ViewUnifiedChange} change */ - public getDiff(change: ViewUnifiedChange): SafeHtml { - const html = this.diff.getChangeDiff(this.motion.text, change, this.lineLength, this.highlightedLine); - return this.sanitizer.bypassSecurityTrustHtml(html); + public getDiff(change: ViewUnifiedChange): string { + return this.diff.getChangeDiff(this.motion.text, change, this.lineLength, this.highlightedLine); } /** @@ -253,9 +250,9 @@ export class MotionDetailDiffComponent extends BaseViewComponent implements Afte return this.changes.find((obj: ViewUnifiedChange) => obj.isTitleChange()); } - public getFormattedTitleDiff(): SafeHtml { + public getFormattedTitleDiff(): string { const change = this.getTitleChangingObject(); - return this.sanitizer.bypassSecurityTrustHtml(this.recoRepo.getTitleChangesAsDiff(this.motion.title, change)); + return this.recoRepo.getTitleChangesAsDiff(this.motion.title, change); } /** diff --git a/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.html b/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.html index 39f5bca3a..56a4ea051 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.html +++ b/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.html @@ -655,7 +655,7 @@ >
@@ -755,7 +755,7 @@ > Reason * -
+
-
-
-
+ +
+
+
diff --git a/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts b/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts index 86dc8c902..b54142206 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts +++ b/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts @@ -4,7 +4,7 @@ import { MatCheckboxChange } from '@angular/material/checkbox'; import { ErrorStateMatcher } from '@angular/material/core'; import { MatDialog } from '@angular/material/dialog'; import { MatSnackBar } from '@angular/material/snack-bar'; -import { DomSanitizer, SafeHtml, Title } from '@angular/platform-browser'; +import { Title } from '@angular/platform-browser'; import { ActivatedRoute, NavigationEnd, Router } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; @@ -22,7 +22,7 @@ import { WorkflowRepositoryService } from 'app/core/repositories/motions/workflo import { TagRepositoryService } from 'app/core/repositories/tags/tag-repository.service'; import { UserRepositoryService } from 'app/core/repositories/users/user-repository.service'; import { ConfigService } from 'app/core/ui-services/config.service'; -import { DiffLinesInParagraph, DiffService, LineRange } from 'app/core/ui-services/diff.service'; +import { DiffLinesInParagraph, LineRange } from 'app/core/ui-services/diff.service'; import { LinenumberingService } from 'app/core/ui-services/linenumbering.service'; import { PersonalNoteService } from 'app/core/ui-services/personal-note.service'; import { PromptService } from 'app/core/ui-services/prompt.service'; @@ -398,12 +398,10 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit, * @param mediafileRepo Mediafile Repository * @param DS The DataStoreService * @param configService The configuration provider - * @param sanitizer For making HTML SafeHTML * @param promptService ensure safe deletion * @param pdfExport export the motion to pdf * @param personalNoteService: personal comments and favorite marker * @param linenumberingService The line numbering service - * @param diffService The diff service * @param categoryRepo Repository for categories * @param viewModelStore accessing view models * @param categoryRepo access the category repository @@ -433,12 +431,10 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit, private changeRecoRepo: ChangeRecommendationRepositoryService, private statuteRepo: StatuteParagraphRepositoryService, private configService: ConfigService, - private sanitizer: DomSanitizer, private promptService: PromptService, private pdfExport: MotionPdfExportService, private personalNoteService: PersonalNoteService, private linenumberingService: LinenumberingService, - private diffService: DiffService, private categoryRepo: CategoryRepositoryService, private userRepo: UserRepositoryService, private notifyService: NotifyService, @@ -861,17 +857,6 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit, return this.repo.formatMotion(this.motion.id, this.crMode, changes, this.lineLength, this.highlightedLine); } - /** - * Called from the template to make a HTML string compatible with [innerHTML] - * (otherwise line-number-data-attributes would be stripped out) - * - * @param {string} text - * @returns {SafeHtml} - */ - public sanitizedText(text: string): SafeHtml { - return this.sanitizer.bypassSecurityTrustHtml(text); - } - /** * If `this.motion` is an amendment, this returns the list of all changed paragraphs. * @@ -882,34 +867,13 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit, return this.repo.getAmendmentParagraphs(this.motion, this.lineLength, includeUnchanged); } - /** - * If `this.motion` is an amendment, this returns a specified line range from the parent motion - * (e.g. to show the contect in which this amendment is happening) - * - * @param from the line number to start - * @param to the line number to stop - * @returns safe html strings - */ - public getParentMotionRange(from: number, to: number): SafeHtml { - const parentMotion = this.repo.getViewModel(this.motion.parent_id); - const str = this.diffService.extractMotionLineRange( - parentMotion.text, - { from, to }, - true, - this.lineLength, - this.highlightedLine - ); - return this.sanitizer.bypassSecurityTrustHtml(str); - } - /** * get the diff html from the statute amendment, as SafeHTML for [innerHTML] * * @returns safe html strings */ - public getFormattedStatuteAmendment(): SafeHtml { - const diffHtml = this.repo.formatStatuteAmendment(this.statuteParagraphs, this.motion, this.lineLength); - return this.sanitizer.bypassSecurityTrustHtml(diffHtml); + public getFormattedStatuteAmendment(): string { + return this.repo.formatStatuteAmendment(this.statuteParagraphs, this.motion, this.lineLength); } public getChangesForDiffMode(): ViewUnifiedChange[] { diff --git a/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.html b/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.html index abc3c012e..786923272 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.html +++ b/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.html @@ -39,7 +39,7 @@ -
+
No personal note
diff --git a/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.ts b/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.ts index a1e6d538f..93266123f 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.ts +++ b/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.ts @@ -1,7 +1,7 @@ import { Component, Input } from '@angular/core'; import { FormBuilder, FormGroup } from '@angular/forms'; import { MatSnackBar } from '@angular/material'; -import { DomSanitizer, SafeHtml, Title } from '@angular/platform-browser'; +import { Title } from '@angular/platform-browser'; import { TranslateService } from '@ngx-translate/core'; @@ -46,7 +46,6 @@ export class PersonalNoteComponent extends BaseViewComponent { * @param personalNoteService * @param formBuilder * @param pdfService - * @param sanitizer */ public constructor( title: Title, @@ -54,8 +53,7 @@ export class PersonalNoteComponent extends BaseViewComponent { matSnackBar: MatSnackBar, private personalNoteService: PersonalNoteService, formBuilder: FormBuilder, - private pdfService: MotionPdfExportService, - private sanitizer: DomSanitizer + private pdfService: MotionPdfExportService ) { super(title, translate, matSnackBar); this.personalNoteForm = formBuilder.group({ @@ -102,15 +100,4 @@ export class PersonalNoteComponent extends BaseViewComponent { public printPersonalNote(): void { this.pdfService.exportPersonalNote(this.motion.personalNote, this.motion); } - - /** - * Sanitize the text to be safe. - * - * @param text to be sanitized. - * - * @returns SafeHtml - */ - public sanitizeText(text: string): SafeHtml { - return this.sanitizer.bypassSecurityTrustHtml(text); - } } diff --git a/client/src/app/site/motions/modules/statute-paragraph/components/statute-paragraph-list/statute-paragraph-list.component.html b/client/src/app/site/motions/modules/statute-paragraph/components/statute-paragraph-list/statute-paragraph-list.component.html index 14fa29e07..99e7ecd07 100644 --- a/client/src/app/site/motions/modules/statute-paragraph/components/statute-paragraph-list/statute-paragraph-list.component.html +++ b/client/src/app/site/motions/modules/statute-paragraph/components/statute-paragraph-list/statute-paragraph-list.component.html @@ -26,7 +26,7 @@ {{ statuteParagraph.title }} -
+
diff --git a/client/src/app/site/topics/components/topic-detail/topic-detail.component.html b/client/src/app/site/topics/components/topic-detail/topic-detail.component.html index b3be68386..c678bef00 100644 --- a/client/src/app/site/topics/components/topic-detail/topic-detail.component.html +++ b/client/src/app/site/topics/components/topic-detail/topic-detail.component.html @@ -32,7 +32,7 @@
-
+
diff --git a/client/src/app/site/topics/components/topic-detail/topic-detail.component.ts b/client/src/app/site/topics/components/topic-detail/topic-detail.component.ts index f0ec63cc4..842a9bab9 100644 --- a/client/src/app/site/topics/components/topic-detail/topic-detail.component.ts +++ b/client/src/app/site/topics/components/topic-detail/topic-detail.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { MatSnackBar } from '@angular/material/snack-bar'; -import { DomSanitizer, SafeHtml, Title } from '@angular/platform-browser'; +import { Title } from '@angular/platform-browser'; import { ActivatedRoute, Router } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; @@ -81,8 +81,7 @@ export class TopicDetailComponent extends BaseViewComponent { private repo: TopicRepositoryService, private promptService: PromptService, private operator: OperatorService, - private itemRepo: ItemRepositoryService, - private sanitizer: DomSanitizer + private itemRepo: ItemRepositoryService ) { super(title, translate, matSnackBar); this.getTopicByUrl(); @@ -241,16 +240,4 @@ export class TopicDetailComponent extends BaseViewComponent { this.setEditMode(false); } } - - /** - * Function to sanitize text. - * Necessary to render styles etc. correctly. - * - * @param text which will be sanitized. - * - * @returns safeHtml which can be displayed whithout loss. - */ - public sanitizedText(text: string): SafeHtml { - return this.sanitizer.bypassSecurityTrustHtml(text); - } } diff --git a/client/src/app/site/users/components/user-detail/user-detail.component.html b/client/src/app/site/users/components/user-detail/user-detail.component.html index a3bfc02c6..2d59fc89b 100644 --- a/client/src/app/site/users/components/user-detail/user-detail.component.html +++ b/client/src/app/site/users/components/user-detail/user-detail.component.html @@ -315,7 +315,7 @@

About me

-
+
diff --git a/client/src/app/site/users/components/user-detail/user-detail.component.ts b/client/src/app/site/users/components/user-detail/user-detail.component.ts index ef04a9115..4160c6c0b 100644 --- a/client/src/app/site/users/components/user-detail/user-detail.component.ts +++ b/client/src/app/site/users/components/user-detail/user-detail.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { MatSnackBar } from '@angular/material/snack-bar'; -import { DomSanitizer, SafeHtml, Title } from '@angular/platform-browser'; +import { Title } from '@angular/platform-browser'; import { ActivatedRoute, Router } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; @@ -97,8 +97,7 @@ export class UserDetailComponent extends BaseViewComponent implements OnInit { private operator: OperatorService, private promptService: PromptService, private pdfService: UserPdfExportService, - private groupRepo: GroupRepositoryService, - private sanitizer: DomSanitizer + private groupRepo: GroupRepositoryService ) { super(title, translate, matSnackBar); // prevent 'undefined' to appear in the ui @@ -422,18 +421,6 @@ export class UserDetailComponent extends BaseViewComponent implements OnInit { this.pdfService.exportSingleUserAccessPDF(this.user); } - /** - * Function to sanitize the text. - * Necessary to render text etc. correctly. - * - * @param text which should be sanitized. - * - * @returns safeHtml which can be displayed. - */ - public sanitizedText(text: string): SafeHtml { - return this.sanitizer.bypassSecurityTrustHtml(text); - } - /** * (Re)- send an invitation email for this user after confirmation */ diff --git a/client/src/app/slides/assignments/assignment/assignment-slide.component.html b/client/src/app/slides/assignments/assignment/assignment-slide.component.html index 512458a7a..368ac2366 100644 --- a/client/src/app/slides/assignments/assignment/assignment-slide.component.html +++ b/client/src/app/slides/assignments/assignment/assignment-slide.component.html @@ -4,7 +4,7 @@

Election

-
+

Candidates

    diff --git a/client/src/app/slides/core/projector-message/projector-message-slide.component.html b/client/src/app/slides/core/projector-message/projector-message-slide.component.html index d5fb346ba..7171242d8 100644 --- a/client/src/app/slides/core/projector-message/projector-message-slide.component.html +++ b/client/src/app/slides/core/projector-message/projector-message-slide.component.html @@ -1,5 +1,5 @@
    -
    +
    diff --git a/client/src/app/slides/core/projector-message/projector-message-slide.component.ts b/client/src/app/slides/core/projector-message/projector-message-slide.component.ts index 94ed37161..9afc9e4dc 100644 --- a/client/src/app/slides/core/projector-message/projector-message-slide.component.ts +++ b/client/src/app/slides/core/projector-message/projector-message-slide.component.ts @@ -1,5 +1,4 @@ import { Component, ViewEncapsulation } from '@angular/core'; -import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; import { BaseSlideComponent } from 'app/slides/base-slide-component'; import { ProjectorMessageSlideData } from './projector-message-slide-data'; @@ -11,11 +10,7 @@ import { ProjectorMessageSlideData } from './projector-message-slide-data'; encapsulation: ViewEncapsulation.None }) export class ProjectorMessageSlideComponent extends BaseSlideComponent { - public constructor(private sanitizer: DomSanitizer) { + public constructor() { super(); } - - public trustHTML(html: string): SafeHtml { - return this.sanitizer.bypassSecurityTrustHtml(html); - } } diff --git a/client/src/app/slides/motions/motion/motion-slide.component.html b/client/src/app/slides/motions/motion/motion-slide.component.html index 3a99bfea6..d9f5b9cea 100644 --- a/client/src/app/slides/motions/motion/motion-slide.component.html +++ b/client/src/app/slides/motions/motion/motion-slide.component.html @@ -1,5 +1,9 @@
    - -
    +
    -
    +

    {{ data.data.identifier }}: @@ -33,65 +37,67 @@

    -
    - - {{ preamble | translate }} - - - -
    + + {{ preamble | translate }} -
    -
    - {{ 'Changed title' | translate }}: + + + +
    +
    +
    {{ 'Changed title' | translate }}:
    +
    -
    +
    -
    -
    - + - -
    - - -
    -
    - No changes at the text. -
    +
    -

    - Line {{ paragraph.diffLineFrom }}: -

    -

    - Line {{ paragraph.diffLineFrom }} - {{ paragraph.diffLineTo - 1 }}: -

    + class="motion-text line-numbers-none" + *ngIf="isStatuteAmendment()" + [innerHTML]="getFormattedStatuteAmendment() | trust: 'html'" + >
    -
    -
    -
    + +
    +
    + No changes at the text. +
    +
    +

    + Line {{ paragraph.diffLineFrom }}: +

    +

    + Line {{ paragraph.diffLineFrom }} - {{ paragraph.diffLineTo - 1 }}: +

    + +
    +
    +
    +
    +
    + + +
    +

    Reason

    +
    -
    - - -
    -

    Reason

    -
    -
    diff --git a/client/src/app/slides/motions/motion/motion-slide.component.ts b/client/src/app/slides/motions/motion/motion-slide.component.ts index de62d207f..7d7a896df 100644 --- a/client/src/app/slides/motions/motion/motion-slide.component.ts +++ b/client/src/app/slides/motions/motion/motion-slide.component.ts @@ -1,5 +1,4 @@ import { Component, Input, ViewEncapsulation } from '@angular/core'; -import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; import { TranslateService } from '@ngx-translate/core'; @@ -114,7 +113,6 @@ export class MotionSlideComponent extends BaseMotionSlideComponent -
    +
    diff --git a/client/src/app/slides/topics/topic/topic-slide.component.ts b/client/src/app/slides/topics/topic/topic-slide.component.ts index 6e2279ebe..2e3a26d45 100644 --- a/client/src/app/slides/topics/topic/topic-slide.component.ts +++ b/client/src/app/slides/topics/topic/topic-slide.component.ts @@ -1,5 +1,4 @@ import { Component } from '@angular/core'; -import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; import { BaseSlideComponent } from 'app/slides/base-slide-component'; import { TopicSlideData } from './topic-slide-data'; @@ -10,19 +9,7 @@ import { TopicSlideData } from './topic-slide-data'; styleUrls: ['./topic-slide.component.scss'] }) export class TopicSlideComponent extends BaseSlideComponent { - public constructor(private sanitizer: DomSanitizer) { + public constructor() { super(); } - - /** - * Function to sanitize text. - * Necessary to render the text correctly. - * - * @param text which should be displayed. - * - * @returns safeHtml which can be displayed. - */ - public sanitizedText(text: string): SafeHtml { - return this.sanitizer.bypassSecurityTrustHtml(text); - } }