XML export mangles <, >, and &

Created on 13 October 2009, over 15 years ago
Updated 8 March 2023, almost 2 years ago

In views_bonus_export.theme.inc are these lines, starting at line 63:

    foreach ($row as $field => $content) {
      $vars['themed_rows'][$num][$field] = str_replace(
        array('&', '<', '>'),
        array('&amp;', '&lt;', '&gt;'),
        $content);
    }

A few problems.

First, there is no need to check for >. The W3C's XML spec sec. 2.4 only says to worry if it's within a CDATA section (because it could conflict with ]]>), but those were removed per πŸ› CDATA is pointless Closed: outdated .

Second, & and < should not be altered unless they are not part of "markup delimiters, or within a comment." For example, if you come across <b>, the opening < should not be altered. Also, if you come across across &amp;, that should not be altered. Unfortunately the current code will convert the tag to &lt;b&gt; and the entity to &amp;amp;. And if either is within a comment, they should be skipped entirely.

πŸ› Bug report
Status

Closed: outdated

Version

1.0

Component

Views Export

Created by

πŸ‡ΊπŸ‡ΈUnited States aren cambre

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024