Fix in text handling to allow UTF-8 characters in frontend#23225
Open
dutra1243 wants to merge 1 commit into
Open
Fix in text handling to allow UTF-8 characters in frontend#23225dutra1243 wants to merge 1 commit into
dutra1243 wants to merge 1 commit into
Conversation
Currently latin characters such as ó or í are not being properly handled. With this fix they work.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses incorrect rendering of Latin/UTF-8 characters (e.g., ó, í) in the time entry calendar popover by decoding HTML entities after sanitization, so text is displayed correctly in the frontend.
Changes:
- Updated the calendar component’s
sanitizedValue()helper to sanitize HTML input and then decode entities viaDOMParser().parseFromString(...).body.textContent. - Added an early return for empty input values.
Comment on lines
+690
to
+696
| private sanitizedValue(value: string): string { | ||
| if (!value) return ''; | ||
|
|
||
| const sanitized = this.sanitizer.sanitize(SecurityContext.HTML, value) ?? ''; | ||
|
|
||
| const parser = new DOMParser(); | ||
| return parser.parseFromString(sanitized, 'text/html').body.textContent || sanitized; |
Comment on lines
+690
to
+696
| private sanitizedValue(value: string): string { | ||
| if (!value) return ''; | ||
|
|
||
| const sanitized = this.sanitizer.sanitize(SecurityContext.HTML, value) ?? ''; | ||
|
|
||
| const parser = new DOMParser(); | ||
| return parser.parseFromString(sanitized, 'text/html').body.textContent || sanitized; |
| private sanitizedValue(value:string):string { | ||
| return this.sanitizer.sanitize(SecurityContext.HTML, value) ?? ''; | ||
| private sanitizedValue(value: string): string { | ||
| if (!value) return ''; |
Comment on lines
+693
to
+696
| const sanitized = this.sanitizer.sanitize(SecurityContext.HTML, value) ?? ''; | ||
|
|
||
| const parser = new DOMParser(); | ||
| return parser.parseFromString(sanitized, 'text/html').body.textContent || sanitized; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What are you trying to accomplish?
Currently latin characters such as ó or í are not being properly handled. With this fix they are shown properly in the frontend.
Screenshots
Before:


After:
What approach did you choose and why?
I modified the component's internal sanitizedValue() helper method to sequentially handle both security and character decoding:
Sanitize First: Utilize Angular's DomSanitizer.sanitize(SecurityContext.HTML, value) to remove potential XSS vectors.
Decode Second: Pass the sanitized string into a browser-native DOMParser().parseFromString() execution to safely parse out the decimal entities into normal Spanish UTF-8 text before it hits the lit-html template.
This approach was chosen because it cleanly centralizes the logic in a pre-existing utility function without complicating the layout template.
Merge checklist