Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
If you're experiencing issues where the

<source>

and

<target>

tags in your XLIFF file show empty CDATA[] instead of the actual text, this might be due to an issue with HTML sanitization in your theme's code.
Solution:
We recommend modifying the

wp_kses_allowed_html

filter in your theme. Specifically, avoid using a wildcard for attributes and instead, explicitly apply the

style

attribute to each allowed tag. Here is a corrected version of the code you can use:

add_filter('wp_kses_allowed_html', function($allowed, $context) {
    if ($context === 'post') {
        if (!isset($allowed['script'])) {
            $allowed['script'] = array();
        }
        $allowed['script'] = array_merge($allowed['script'], array(
            'src' => true,
            'type' => true,
            'charset' => true,
            'data-*' => true,
            'defer' => true,
            'async' => true,
        ));

        if (!isset($allowed['style'])) {
            $allowed['style'] = array();
        }
        $allowed['style'] = array_merge($allowed['style'], array(
            'type' => true,
            'media' => true,
            'scoped' => true,
        ));

        // Properly allow inline styles on a per-tag basis
        foreach ($allowed as $tag => &$attributes) {
            if (is_array($attributes)) {
                $attributes['style'] = true;
            }
        }
    }
    return $allowed;
}, 10, 2);

Please try this solution and let us know if it resolves the issue.

If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 0 replies, has 0 voices.

Last updated by Bruno Kos 1 week ago.

Assisted by: Bruno Kos.

Author Posts
April 17, 2025 at 5:07 am

lrn-accountsP

Background of the issue:
I have exported the XLIFF file as per my old process. When I open the XLIFF file, I do not see text in the and tags. They show "" this type of data. Not actually text coming. Link to a page where the issue can be seen: hidden link

Symptoms:
The and CDATA[] are empty in the XLIFF file.

Questions:
Why are the and tags showing empty CDATA[]?
How can I ensure the actual text appears in the XLIFF file?
Why does this happen only on the updated version?

April 17, 2025 at 6:38 am
April 17, 2025 at 6:43 am #16942052

lrn-accountsP

Can you please tell me you have found an issue?

April 17, 2025 at 8:47 am #16942808

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+02:00)

Given its complexity, it will take a bit more time to investigate thoroughly. I’ll keep you updated as we make progress and will share any findings as soon as we have something concrete.

April 17, 2025 at 1:12 pm #16944127

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+02:00)

This has been escalated to our 2nd tier team team and may take some debugging time, I'll get back to you as soon as I have any news or questions for you.

April 23, 2025 at 5:07 am #16957850

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+02:00)

We’ve reviewed your theme code modifying the `wp_kses_allowed_html` filter and identified an issue that may cause problems with WordPress’s HTML sanitization.

The current implementation in your theme includes the following line:

$allowed['*']['style'] = true;

This use of a wildcard (`'*'`) is not supported by WordPress's KSES system and results in invalid regular expressions being generated during sanitization, which can lead to errors or unpredictable behavior. For example:

7cod/(<\s*(?:...|style|*)\b[^>]*>)/m

To address this, we recommend updating the code to explicitly apply the `style` attribute to each allowed tag instead of relying on a wildcard. Here's the corrected and complete version of the code that may work:

add_filter('wp_kses_allowed_html', function($allowed, $context) {
    if ($context === 'post') {
        if (!isset($allowed['script'])) {
            $allowed['script'] = array();
        }
        $allowed['script'] = array_merge($allowed['script'], array(
            'src' => true,
            'type' => true,
            'charset' => true,
            'data-*' => true,
            'defer' => true,
            'async' => true,
        ));

        if (!isset($allowed['style'])) {
            $allowed['style'] = array();
        }
        $allowed['style'] = array_merge($allowed['style'], array(
            'type' => true,
            'media' => true,
            'scoped' => true,
        ));

        // Properly allow inline styles on a per-tag basis
        foreach ($allowed as $tag => &$attributes) {
            if (is_array($attributes)) {
                $attributes['style'] = true;
            }
        }
    }
    return $allowed;
}, 10, 2);

This version maintains the desired flexibility with `style` attributes while preserving compatibility with WordPress’s built-in sanitization mechanisms.

Please try and let us know if this works!