From 4c3003e6f0e07286fe3f616205106900229edf7d Mon Sep 17 00:00:00 2001 From: Venkat Kandagaddala Date: Wed, 28 Aug 2024 17:47:43 +0530 Subject: [PATCH] Prevent input text boxes with HTML and javascript --- .../create-event/create-event.component.html | 10 + .../create-event/create-event.component.ts | 7 +- .../edit-event/edit-event.component.html | 12 +- .../events/edit-event/edit-event.component.ts | 7 +- .../request-copy-details.component.html | 549 +++++++++--------- .../request-copy-details.component.ts | 23 +- .../requests-approval.component.html | 8 +- .../requests-approval.component.ts | 3 +- .../edit-sector/edit-sector.component.html | 3 +- .../edit-sector/edit-sector.component.ts | 15 +- .../prevent-html-and-js.validator.ts | 12 + 11 files changed, 363 insertions(+), 286 deletions(-) create mode 100644 project/ws/app/src/lib/routes/home/validators/prevent-html-and-js.validator.ts diff --git a/project/ws/app/src/lib/routes/home/routes/events/create-event/create-event.component.html b/project/ws/app/src/lib/routes/home/routes/events/create-event/create-event.component.html index 3f87546a..e43b1db3 100644 --- a/project/ws/app/src/lib/routes/home/routes/events/create-event/create-event.component.html +++ b/project/ws/app/src/lib/routes/home/routes/events/create-event/create-event.component.html @@ -132,6 +132,12 @@ createEventForm?.controls['description'].errors?.required"> Description is mandatory + + HTML and javascript is not allowed + {{description.value.length}}/1000 characters @@ -149,6 +155,10 @@ *ngIf="createEventForm?.controls['agenda']?.touched && createEventForm?.controls['agenda'].errors?.required"> Agenda is mandatory + + HTML and javascript is not allowed + {{agenda.value.length}}/500 characters diff --git a/project/ws/app/src/lib/routes/home/routes/events/create-event/create-event.component.ts b/project/ws/app/src/lib/routes/home/routes/events/create-event/create-event.component.ts index 4bdc8592..0a19a35f 100644 --- a/project/ws/app/src/lib/routes/home/routes/events/create-event/create-event.component.ts +++ b/project/ws/app/src/lib/routes/home/routes/events/create-event/create-event.component.ts @@ -15,6 +15,7 @@ import { MomentDateAdapter } from '@angular/material-moment-adapter' import _ from 'lodash' import { TelemetryEvents } from '../../events/model/telemetry.event.model' import { ProfileV2UtillService } from '../services/home-utill.service' +import { preventHtmlAndJs } from '../../../validators/prevent-html-and-js.validator' /* tslint:enable */ export const MY_FORMATS = { @@ -146,8 +147,8 @@ export class CreateEventComponent implements OnInit { eventPicture: new FormControl('', [Validators.required]), eventTitle: new FormControl('', [Validators.required]), // summary: new FormControl('', [Validators.required]), - description: new FormControl('', [Validators.required]), - agenda: new FormControl('', []), + description: new FormControl('', [Validators.required, preventHtmlAndJs()]), + agenda: new FormControl('', [preventHtmlAndJs()]), // isItKarmayogiTalk: new FormControl('', []), eventType: new FormControl('', [Validators.required]), eventDate: new FormControl('', [Validators.required]), @@ -580,7 +581,7 @@ export class CreateEventComponent implements OnInit { this.dialogRef.afterClosed().subscribe(() => { setTimeout(() => { this.router.navigate([`/app/home/events`]) - }, 700) + }, 700) }) } diff --git a/project/ws/app/src/lib/routes/home/routes/events/edit-event/edit-event.component.html b/project/ws/app/src/lib/routes/home/routes/events/edit-event/edit-event.component.html index cdafcd55..68718b3a 100644 --- a/project/ws/app/src/lib/routes/home/routes/events/edit-event/edit-event.component.html +++ b/project/ws/app/src/lib/routes/home/routes/events/edit-event/edit-event.component.html @@ -135,9 +135,15 @@ + createEventForm?.controls['description'].errors?.required"> Description is mandatory + + HTML and javascript is not allowed + {{description.value.length}}/1000 characters @@ -155,6 +161,10 @@ *ngIf="createEventForm?.controls['agenda']?.touched && createEventForm?.controls['agenda'].errors?.required"> Agenda is mandatory + + HTML or Js is not allowed + {{agenda.value.length}}/500 characters diff --git a/project/ws/app/src/lib/routes/home/routes/events/edit-event/edit-event.component.ts b/project/ws/app/src/lib/routes/home/routes/events/edit-event/edit-event.component.ts index cefa3acb..4e423df9 100644 --- a/project/ws/app/src/lib/routes/home/routes/events/edit-event/edit-event.component.ts +++ b/project/ws/app/src/lib/routes/home/routes/events/edit-event/edit-event.component.ts @@ -15,6 +15,7 @@ import _ from 'lodash' import { TelemetryEvents } from '../model/telemetry.event.model' import { ProfileV2UtillService } from '../services/home-utill.service' import { MomentDateAdapter } from '@angular/material-moment-adapter' +import { preventHtmlAndJs } from '../../../validators/prevent-html-and-js.validator' /* tslint:enable */ export const MY_FORMATS = { @@ -151,8 +152,8 @@ export class EditEventComponent implements OnInit { eventPicture: new FormControl('', [Validators.required]), eventTitle: new FormControl('', [Validators.required]), // summary: new FormControl('', []), - description: new FormControl('', [Validators.required]), - agenda: new FormControl('', []), + description: new FormControl('', [Validators.required, preventHtmlAndJs()]), + agenda: new FormControl('', [preventHtmlAndJs()]), // isItKarmayogiTalk: new FormControl('', []), eventType: new FormControl('', [Validators.required]), eventDate: new FormControl('', [Validators.required]), @@ -574,7 +575,7 @@ export class EditEventComponent implements OnInit { this.displayLoader = false this.openSnackbar('Event details are successfuly updated.') this.router.navigate([`/app/home/events`]) - }, 5000) + }, 5000) } }, (err: any) => { diff --git a/project/ws/app/src/lib/routes/home/routes/request/request-copy-details/request-copy-details.component.html b/project/ws/app/src/lib/routes/home/routes/request/request-copy-details/request-copy-details.component.html index a606e644..4f09d355 100644 --- a/project/ws/app/src/lib/routes/home/routes/request/request-copy-details/request-copy-details.component.html +++ b/project/ws/app/src/lib/routes/home/routes/request/request-copy-details/request-copy-details.component.html @@ -1,278 +1,301 @@
- - - arrow_back - - {{isHideData ? 'Go Back':'Request Content'}} - - - - -
-
-
-
Title
- - - {{ requestForm.controls['titleName'].value.length }} / 70 - - Please enter a title for the request. - - - Minimum characters left to create {{10 - requestForm.controls['titleName'].value.length}} - - - Only {{specialCharList}} characters are supported - - - Only {{specialCharList}} characters are supported - - + + + arrow_back + + {{isHideData ? 'Go Back':'Request Content'}} + + + + +
+ +
+
Title
+ + + {{ requestForm.controls['titleName'].value.length }} / 70 + + Please enter a title for the request. + + + Minimum characters left to create {{10 - requestForm.controls['titleName'].value.length}} + + + Only {{specialCharList}} characters are supported + + + HTML or Js is not allowed + + + Only {{specialCharList}} characters are supported + + +
+
+
Objective
+ + + + {{ requestForm.controls['Objective'].value.length }} / 500 + + Please enter the objective of the request. + + + Minimum characters left to create {{10 - requestForm.controls['Objective'].value.length}} + + + HTML or Js is not allowed + + + Only {{specialCharList}} characters are supported + + + Only {{specialCharList}} characters are supported + + +
+
+
Type of user
+ + + + {{ requestForm.controls['userType'].value.length }} / 500 + + Minimum characters left to create {{10 - requestForm.controls['userType'].value.length}} + + + HTML or Js is not allowed + + + Only {{specialCharList}} characters are supported + + + Only {{specialCharList}} characters are supported + + +
+
+
Learning Mode
+
+ + {{item.name}} + + +
+
+ +
+ Targeted Competencies +
+
+

Competency Area

+ + + + {{option.name}} + + + +
+ +
+

Competency Theme

+ -
-
Objective
- - - - {{ requestForm.controls['Objective'].value.length }} / 500 - - Please enter the objective of the request. - - - Minimum characters left to create {{10 - requestForm.controls['Objective'].value.length}} - - - Only {{specialCharList}} characters are supported - - - Only {{specialCharList}} characters are supported - - +
+ {{option.name}}
-
-
Type of user
- - - - {{ requestForm.controls['userType'].value.length }} / 500 - - Minimum characters left to create {{10 - requestForm.controls['userType'].value.length}} - - - Only {{specialCharList}} characters are supported - - - Only {{specialCharList}} characters are supported - - +
+ +
+

Competency Sub theme

+ -
-
Learning Mode
-
- - {{item.name}} - - -
+
+ {{option.name}}
- -
- Targeted Competencies -
-
-

Competency Area

- - - - {{option.name}} - - - -
- -
-

Competency Theme

- -
- {{option.name}} -
-
- -
-

Competency Sub theme

- -
- {{option.name}} -
-
- -
- -
-
-
-
-
- - - - - - - - - - - -
AreaThemeSub theme
{{comp.competencyArea}}{{comp.competencyTheme || comp.name}}{{comp.competencySubTheme || - comp.selectedLevelLevel}}
-
+
+ +
+ +
+
+
+
+
+ + + + + + + + + + + +
AreaThemeSub theme
{{comp.competencyArea}}{{comp.competencyTheme || comp.name}}{{comp.competencySubTheme || + comp.selectedLevelLevel}}
-
- -
-
-
-
Refrence Link
- - - +
+
+
+
Refrence Link
+ + + + HTML or Js is not allowed + + - -
-
-
Request Type
-
- - {{item}} - - -
-
-
-
Assignee
-
- - - - {{option.orgName}} - - - -
-
-
-
Preffered Providers - - info - -
-
- - - - - - - {{ item.orgName }} - cancel - - - - - - - - - - -
No results found!
-
- {{option.orgName}} - -
-
-
-
+
+
+
Request Type
+
+ + {{item}} + + +
+
+
+
Assignee
+
+ + + + {{option.orgName}} + + + +
+
+
+
Preffered Providers + + info + + +
+
+ + + + + + + {{ item.orgName }} + cancel + + + + + + + + + + +
No results found!
+
+ {{option.orgName}} + +
+
+
+
+ +
+ + + +
+ +
+ -
- - - -
+
+ +
-
- - -
- -
- - - -
\ No newline at end of file + + +
\ No newline at end of file diff --git a/project/ws/app/src/lib/routes/home/routes/request/request-copy-details/request-copy-details.component.ts b/project/ws/app/src/lib/routes/home/routes/request/request-copy-details/request-copy-details.component.ts index 2fac52e8..aecc49b2 100644 --- a/project/ws/app/src/lib/routes/home/routes/request/request-copy-details/request-copy-details.component.ts +++ b/project/ws/app/src/lib/routes/home/routes/request/request-copy-details/request-copy-details.component.ts @@ -8,6 +8,7 @@ import { ConfirmationPopupComponent } from '../confirmation-popup/confirmation-p /* tslint:disable */ import _ from 'lodash' import { debounceTime, distinctUntilChanged, startWith } from 'rxjs/operators' +import { preventHtmlAndJs } from '../../../validators/prevent-html-and-js.validator' /* tslint:enable */ @Component({ @@ -70,22 +71,22 @@ export class RequestCopyDetailsComponent implements OnInit { competencySubtheme!: FormControl constructor(private formBuilder: FormBuilder, - private requestService: RequestServiceService, - private activatedRouter: ActivatedRoute, - private snackBar: MatSnackBar, - private router: Router, - public dialog: MatDialog + private requestService: RequestServiceService, + private activatedRouter: ActivatedRoute, + private snackBar: MatSnackBar, + private router: Router, + public dialog: MatDialog ) { this.currentUser = sessionStorage.getItem('idDetails') ? sessionStorage.getItem('idDetails') : '' this.requestForm = this.formBuilder.group({ - titleName: new FormControl('', [Validators.required, Validators.pattern(this.noSpecialChar), Validators.minLength(10)]), - Objective: new FormControl('', [Validators.required, Validators.pattern(this.noSpecialChar)]), - userType: new FormControl('', [Validators.pattern(this.noSpecialChar)]), + titleName: new FormControl('', [Validators.required, preventHtmlAndJs(), Validators.pattern(this.noSpecialChar), Validators.minLength(10)]), + Objective: new FormControl('', [Validators.required, preventHtmlAndJs(), Validators.pattern(this.noSpecialChar)]), + userType: new FormControl('', [preventHtmlAndJs(), Validators.pattern(this.noSpecialChar)]), learningMode: new FormControl(''), compArea: new FormControl(''), - referenceLink: new FormControl(''), + referenceLink: new FormControl('', preventHtmlAndJs()), requestType: new FormControl('', Validators.required), assignee: new FormControl(''), providers: new FormControl([[]]), @@ -651,9 +652,9 @@ export class RequestCopyDetailsComponent implements OnInit { this.router.navigateByUrl('/app/home/all-request') this.snackBar.open('Request submitted successfully ') } - }, 1000) + }, 1000) }, - (error: any) => { + (error: any) => { this.dialogRefs.close({ error }) this.snackBar.open('Request Failed') diff --git a/project/ws/app/src/lib/routes/home/routes/requests-approval/requests-approval.component.html b/project/ws/app/src/lib/routes/home/routes/requests-approval/requests-approval.component.html index 0ebd168b..b04c4ccf 100644 --- a/project/ws/app/src/lib/routes/home/routes/requests-approval/requests-approval.component.html +++ b/project/ws/app/src/lib/routes/home/routes/requests-approval/requests-approval.component.html @@ -102,9 +102,15 @@

{{ newPosition ? 'Add new - + Description is not valid + + HTML or Js is not allowed +

diff --git a/project/ws/app/src/lib/routes/home/routes/requests-approval/requests-approval.component.ts b/project/ws/app/src/lib/routes/home/routes/requests-approval/requests-approval.component.ts index 59ffb530..3f35c22b 100644 --- a/project/ws/app/src/lib/routes/home/routes/requests-approval/requests-approval.component.ts +++ b/project/ws/app/src/lib/routes/home/routes/requests-approval/requests-approval.component.ts @@ -6,6 +6,7 @@ import { DialogConfirmComponent } from '../../../../../../../../../src/app/compo import { RequestsService } from '../../services/onboarding-requests.service' import { RejectReasonDialogComponent } from '../reject-reason-dialog/reject-reason-dialog.component' import * as _ from 'lodash' +import { preventHtmlAndJs } from '../../validators/prevent-html-and-js.validator' @Component({ selector: 'ws-app-requests-approval', @@ -68,7 +69,7 @@ export class RequestsApprovalComponent implements OnInit { position: new FormControl(this.requestType === 'position' ? this.posData.position : '', this.requestType === 'position' ? [Validators.required, Validators.maxLength(500), Validators.pattern(this.customCharsPattern)] : []), organisation: new FormControl(this.requestType === 'organisation' ? this.posData.organisation : '', this.requestType === 'organisation' ? [Validators.required, Validators.pattern(this.customCharsPattern)] : []), domain: new FormControl(this.requestType === 'domain' ? this.posData.domain : '', this.requestType === 'domain' ? [Validators.required, Validators.pattern(this.domainPattern)] : []), - description: new FormControl(this.posData.description, []), + description: new FormControl(this.posData.description, [preventHtmlAndJs()]), wfId: new FormControl(this.posData.wfId), }) diff --git a/project/ws/app/src/lib/routes/home/routes/sectors/edit-sector/edit-sector.component.html b/project/ws/app/src/lib/routes/home/routes/sectors/edit-sector/edit-sector.component.html index 5939867f..78ce4cff 100644 --- a/project/ws/app/src/lib/routes/home/routes/sectors/edit-sector/edit-sector.component.html +++ b/project/ws/app/src/lib/routes/home/routes/sectors/edit-sector/edit-sector.component.html @@ -72,7 +72,8 @@
- +