legacy-knowledge-base
公開されました Sep. 10, 2025

Unwanted spaces appearing after HTML tags in translated text

written-by

Jorge Diaz

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

Issue

  • When using HTML tags like <strong>, <b>, <h1>, <span>, and <i> within internationalized text in the Language Override functionality, an unnecessary space is generated after the closing tag when the text is rendered in a fragment
  • This extra space is visible in both the displayed text and the translation list.
  • The issue occurs if any character follows the closing HTML tag. If the translated text ends with the closing tag, the problem does not occur.

Environment

  • Quarterly Releases
  • DXP 2024.Q2, 2024.Q3

Resolution

  • The issue is caused by the AntiSamy filter, that it is adding a carriage return after the HTML tags.
  • To resolve the problem, disable the AntiSamy filter for Language Override functionality.
  • Add com.liferay.portal.language.override.model.PLOEntry to the AntiSamy whitelist.
    1. Go to the Control Panel > Configuration > System Settings.
    2. Navigate to Security Tools > AntiSamy Sanitizer
    3. Add a new entry for com.liferay.portal.language.override.model.PLOEntry in the whitelist.
    4. Save your changes.
  • For more information, se also: Spaces are removed from the translation when it is longer than 75 characters.
  • Alternatively, you can create a custom AntiSamy policy specifically for PLOEntry. This allows you to maintain AntiSamy functionality while addressing the space issue.
  • To configure a custom policy:
    1. Review the documentation on using AntiSamy: Using AntiSamy
    2. Refer to LPS-112978 for a related issue and further context.
    3. Create a custom sanitizer-configuration.xml file for PLOEntry. In this file, remove or modify the formatOutput instruction, which is responsible for adding the carriage return (and subsequently the extra space).
  • As another option, use HTML entities for the "<" and ">" symbols within the internationalized text. For example:
    &lt;strong&gt;This text is bold&lt;/strong&gt;
    

 

 

 

did-this-article-resolve-your-issue

legacy-knowledge-base