Special charaacter bug solved

This commit is contained in:
Eudes Inácio
2023-12-01 12:19:20 +01:00
parent c978447eb1
commit d3c551dfbb
5 changed files with 62 additions and 10 deletions
+14 -3
View File
@@ -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<any>(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);
})
);
+2 -2
View File
@@ -258,9 +258,9 @@
</div>
<div class="schedule-details">
<div class="description">
<p class="m-0">{{event.event.Subject}}</p>
<p class="m-0" [innerHTML]="event.event.Subject">{{event.event.Subject}}</p>
</div>
<div class="location">{{event.event.Location}}</div>
<div class="location" [innerHTML]="event.event.Location">{{event.event.Location}}</div>
<div class="font-13 calendar-owner"*ngIf="eventService.getCalendarOwnNameByCalendarId(event.event.CalendarId) == 'Meu calendario'">{{SessionStore.user.FullName}} </div>
<ng-template #other_content>{{eventService.getCalendarOwnNameByCalendarId(event.event.CalendarId)}}</ng-template>
</div>
+43 -2
View File
@@ -24,13 +24,54 @@ export class DomSanitizerService {
}
private encodeSpecialCharacters(input: string): string {
const specialCharactersMap: Record<string, string> = {
'!': '&#33;',
'@': '&#64;',
'#': '&#35;',
'$': '&#36;',
'%': '&#37;',
'^': '&#94;',
'&': '&#38;',
'*': '&#42;',
'(': '&#40;',
')': '&#41;',
'-': '&#45;',
'_': '&#95;',
'+': '&#43;',
'=': '&#61;',
'{': '&#123;',
'}': '&#125;',
'|': '&#124;',
'\\': '&#92;',
':': '&#58;',
';': '&#59;',
'"': '&#34;',
"'": '&#39;',
'<': '&#60;',
'>': '&#62;',
',': '&#44;',
'.': '&#46;',
'?': '&#63;',
'/': '&#47;',
'ã': '&atilde;', // ã
'ç': '&ccedil;', // ç
'Â': '&Acirc;', // Â
'â': '&acirc;', // â
'Ã': '&Atilde;', // Ã
};
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, '&lt;').replace(/>/g, '&gt;'); */
}
// }
/* sanitizeInput(input: string): string {
return this.sanitizer.sanitize(SecurityContext.HTML, input);
@@ -13,7 +13,7 @@
</button>
</div>
<div class="middle" (click)="openOptions()">
<p class="title">{{loadedEvent.Subject}}</p>
<p class="title" [innerHTML]="loadedEvent.Subject">{{loadedEvent.Subject}}</p>
</div>
<div class="div-icon d-flex align-base">
@@ -54,7 +54,7 @@
<div class="upper-content">
<div class="content-location">
<span class="date">{{loadedEvent.Location}}</span>
<span class="date" [innerHTML]="loadedEvent.Location">{{loadedEvent.Location}}</span>
<div *ngIf="loadedEvent.Organizer">
@@ -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)