Skip to content

Commit

Permalink
fix: wishlist and order template titles with special characters do no…
Browse files Browse the repository at this point in the history
…t displayed correct (#1658)

* special characters in the title like ä,ö,ü
  • Loading branch information
shauke authored May 15, 2024
1 parent 112f11e commit 42864a7
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/app/core/pipes/html-encode.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'ishHtmlEncode', pure: true })
export class HtmlEncodePipe implements PipeTransform {
transform(value: string): string {
return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
return value?.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Injectable, SecurityContext, inject } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { Injectable } from '@angular/core';

import { AttributeHelper } from 'ish-core/models/attribute/attribute.helper';
import { Attribute } from 'ish-core/models/attribute/attribute.model';
Expand All @@ -9,8 +8,6 @@ import { OrderTemplate, OrderTemplateItem } from './order-template.model';

@Injectable({ providedIn: 'root' })
export class OrderTemplateMapper {
private sanitizer = inject(DomSanitizer);

private static parseIdFromURI(uri: string): string {
const match = /wishlists[^\/]*\/([^\?]*)/.exec(uri);
if (match) {
Expand Down Expand Up @@ -43,7 +40,7 @@ export class OrderTemplateMapper {

return {
id: orderTemplateId,
title: this.sanitizer.sanitize(SecurityContext.HTML, orderTemplateData.title),
title: orderTemplateData.title,
itemsCount: orderTemplateData.itemsCount || 0,
creationDate: orderTemplateData.creationDate,
items,
Expand All @@ -57,7 +54,7 @@ export class OrderTemplateMapper {
if (orderTemplate && id) {
return {
id,
title: this.sanitizer.sanitize(SecurityContext.HTML, orderTemplate.title),
title: orderTemplate.title,
creationDate: orderTemplate.creationDate,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('Order Template Service', () => {
"id": "1234",
"items": [],
"itemsCount": 0,
"title": null,
"title": undefined,
},
]
`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h2 class="modal-title">{{ headerTranslationKey | translate }}</h2>
| translate
: {
'0': product.name,
'1': selectedOrderTemplateTitle$ | async,
'1': selectedOrderTemplateTitle$ | async | ishHtmlEncode,
'2': selectedOrderTemplateRoute$ | async
}
"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Injectable, SecurityContext, inject } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { Injectable } from '@angular/core';

import { AttributeHelper } from 'ish-core/models/attribute/attribute.helper';
import { Attribute } from 'ish-core/models/attribute/attribute.model';
Expand All @@ -9,8 +8,6 @@ import { Wishlist, WishlistItem } from './wishlist.model';

@Injectable({ providedIn: 'root' })
export class WishlistMapper {
private sanitizer = inject(DomSanitizer);

private static parseIdFromURI(uri: string): string {
const match = /wishlists[^\/]*\/([^\?]*)/.exec(uri);
if (match) {
Expand Down Expand Up @@ -43,7 +40,7 @@ export class WishlistMapper {
}
return {
id: wishlistId,
title: this.sanitizer.sanitize(SecurityContext.HTML, wishlistData.title),
title: wishlistData.title,
itemsCount: wishlistData.itemsCount || 0,
preferred: wishlistData.preferred,
public: wishlistData.public,
Expand All @@ -58,7 +55,7 @@ export class WishlistMapper {
if (wishlist && id) {
return {
id,
title: this.sanitizer.sanitize(SecurityContext.HTML, wishlist.title),
title: wishlist.title,
preferred: wishlist.preferred,
public: wishlist.public,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('Wishlist Service', () => {
"itemsCount": 0,
"preferred": true,
"public": undefined,
"title": null,
"title": undefined,
},
]
`);
Expand All @@ -75,7 +75,7 @@ describe('Wishlist Service', () => {
"itemsCount": 0,
"preferred": true,
"public": undefined,
"title": null,
"title": undefined,
},
]
`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ <h2 class="modal-title">{{ headerTranslationKey | translate }}</h2>
[ishServerHtml]="
successTranslationKey
| translate
: { '0': product.name, '1': (selectedWishlistRoute$ | async), '2': (selectedWishlistTitle$ | async) }
: {
'0': product.name,
'1': (selectedWishlistRoute$ | async),
'2': (selectedWishlistTitle$ | async | ishHtmlEncode)
}
"
[callbacks]="{ callbackHideDialogModal: callbackHideDialogModal }"
data-testing-id="wishlist-success-link"
Expand Down

0 comments on commit 42864a7

Please sign in to comment.