From d3c551dfbbe4d7b1367fa79047792113dd46f0cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eudes=20In=C3=A1cio?= Date: Fri, 1 Dec 2023 12:19:20 +0100 Subject: [PATCH] Special charaacter bug solved --- src/app/interceptors/token.interceptors.ts | 17 +++++-- src/app/pages/agenda/agenda.page.html | 4 +- src/app/services/DomSanitizer.service.ts | 45 ++++++++++++++++++- .../agenda/view-event/view-event.page.html | 4 +- .../new-publication/new-publication.page.ts | 2 +- 5 files changed, 62 insertions(+), 10 deletions(-) diff --git a/src/app/interceptors/token.interceptors.ts b/src/app/interceptors/token.interceptors.ts index 8a93d2e2f..31734ca61 100644 --- a/src/app/interceptors/token.interceptors.ts +++ b/src/app/interceptors/token.interceptors.ts @@ -13,6 +13,7 @@ import { Observable, throwError, BehaviorSubject, of } from "rxjs"; import { catchError, filter, take, switchMap, tap } from "rxjs/operators"; import { SessionStore } from '../store/session.service'; import { environment } from "src/environments/environment"; +import { Router } from "@angular/router"; @Injectable() export class TokenInterceptor implements HttpInterceptor { @@ -21,7 +22,7 @@ export class TokenInterceptor implements HttpInterceptor { null ); - constructor(private http: HttpClient) { } + constructor(private http: HttpClient, private router: Router,) { } intercept( @@ -74,10 +75,10 @@ export class TokenInterceptor implements HttpInterceptor { } } - + //this method refresh token is declared here temporary beacouse a circular error refreshToken() { - + return this.http .put(environment.apiURL + "UserAuthentication/RefreshToken", { refreshToken: SessionStore.user.RefreshToken, @@ -92,6 +93,16 @@ export class TokenInterceptor implements HttpInterceptor { catchError((error) => { SessionStore.user.Authorization = ""; SessionStore.user.RefreshToken = ""; + SessionStore.setInativity(false) + /* SessionStore.setUrlBeforeInactivity(this.router.url); */ + + if (environment.production) { + window.location.pathname = '/auth' + } else { + /* const pathBeforeGoOut = window.location.pathname */ + this.router.navigateByUrl('/auth', { replaceUrl: true }); + + } return of(false); }) ); diff --git a/src/app/pages/agenda/agenda.page.html b/src/app/pages/agenda/agenda.page.html index 6da2c31de..0058cf67f 100644 --- a/src/app/pages/agenda/agenda.page.html +++ b/src/app/pages/agenda/agenda.page.html @@ -258,9 +258,9 @@
-

{{event.event.Subject}}

+

{{event.event.Subject}}

-
{{event.event.Location}}
+
{{event.event.Location}}
{{SessionStore.user.FullName}}
{{eventService.getCalendarOwnNameByCalendarId(event.event.CalendarId)}}
diff --git a/src/app/services/DomSanitizer.service.ts b/src/app/services/DomSanitizer.service.ts index 00ed43a20..9a907416d 100644 --- a/src/app/services/DomSanitizer.service.ts +++ b/src/app/services/DomSanitizer.service.ts @@ -24,13 +24,54 @@ export class DomSanitizerService { } private encodeSpecialCharacters(input: string): string { + const specialCharactersMap: Record = { + '!': '!', + '@': '@', + '#': '#', + '$': '$', + '%': '%', + '^': '^', + '&': '&', + '*': '*', + '(': '(', + ')': ')', + '-': '-', + '_': '_', + '+': '+', + '=': '=', + '{': '{', + '}': '}', + '|': '|', + '\\': '\', + ':': ':', + ';': ';', + '"': '"', + "'": ''', + '<': '<', + '>': '>', + ',': ',', + '.': '.', + '?': '?', + '/': '/', + 'ã': 'ã', // ã + 'ç': 'ç', // ç + 'Â': 'Â', //  + 'â': 'â', // â + 'Ã': 'Ã', // à + }; + + return input.replace(/[!@#$%^&*()-_+=\{\}|\\:;"'<>,.?/ãçÂâÃ]/g, match => specialCharactersMap[match] || match); + } + + + // private encodeSpecialCharacters(input: string): string { // You can use a library like DOMPurify to encode special characters - return DOMPurify.sanitize(input); + // return DOMPurify.sanitize(input); // If you don't want to use an external library, you can manually encode // Here's a simple example, you may need to extend this based on your requirements /* return input.replace(//g, '>'); */ - } + // } /* sanitizeInput(input: string): string { return this.sanitizer.sanitize(SecurityContext.HTML, input); diff --git a/src/app/shared/agenda/view-event/view-event.page.html b/src/app/shared/agenda/view-event/view-event.page.html index 3cd10fa57..6c4794de4 100644 --- a/src/app/shared/agenda/view-event/view-event.page.html +++ b/src/app/shared/agenda/view-event/view-event.page.html @@ -13,7 +13,7 @@
-

{{loadedEvent.Subject}}

+

{{loadedEvent.Subject}}

@@ -54,7 +54,7 @@
- {{loadedEvent.Location}} + {{loadedEvent.Location}}
diff --git a/src/app/shared/publication/new-publication/new-publication.page.ts b/src/app/shared/publication/new-publication/new-publication.page.ts index a9db08447..834158dce 100644 --- a/src/app/shared/publication/new-publication/new-publication.page.ts +++ b/src/app/shared/publication/new-publication/new-publication.page.ts @@ -199,7 +199,7 @@ export class NewPublicationPage implements OnInit { multiple: true, }); result.files.forEach(async element => { - if(this.checkFileType.checkFileType(element.mimeType) == 'image') { + if(this.checkFileType.checkFileType(element.mimeType) == 'image' || this.checkFileType.checkFileType(element.mimeType) == 'video') { this.convertBlobToBase64(element.blob).then((value) => { console.log(element.mimeType)