Skip to content

Fix in text handling to allow UTF-8 characters in frontend#23225

Open
dutra1243 wants to merge 1 commit into
opf:devfrom
dutra1243:patch-1
Open

Fix in text handling to allow UTF-8 characters in frontend#23225
dutra1243 wants to merge 1 commit into
opf:devfrom
dutra1243:patch-1

Conversation

@dutra1243
Copy link
Copy Markdown

@dutra1243 dutra1243 commented May 15, 2026

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:
image
After:
image

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

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

Currently latin characters such as ó or í are not being properly handled. With this fix they work.
Copilot AI review requested due to automatic review settings May 15, 2026 14:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 via DOMParser().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;
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants