Field data should not be altered in the entity when viewing a link field

Created on 1 December 2011, almost 13 years ago
Updated 31 August 2024, 3 months ago

Steps to reproduce:

$nid = // Some nid of a node that has a link with the title 'Foo & Bar' linked to 'http://example.com/'.
$node = node_load($nid);
debug($node->field_link);
node_view($node, 'full');
debug($node->field_link);

The first debug after node_load() will look like:

array (
  'und' => 
  array (
    0 => 
    array (
      'url' => 'http://example.com/',
      'title' => 'Foo & Bar',
      'attributes' => 
      array (
      ),
    ),
  ),
)

The second debug() after the call to node_view() results in:

array (
  'und' => 
  array (
    0 => 
    array (
      'url' => ''http://example.com/',
      'title' => 'Foo & Bar',
      'attributes' => 
      array (
      ),
      'display_url' => 'http://example.com/',
      'html' => true,
    ),
  ),
)

Notice the 'title' attribute has been escaped. Now if I'm trying to use this raw link data to output elsewhere, I'm screwed. The link module should *not* be altering field data on the node. If we were to call node_save() after this code, it would result in data loss as Foo & Bar would be saved as the 'title' value in the field.

πŸ› Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States dave reid Nebraska USA

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

Comments & Activities

  • πŸ‡«πŸ‡·France dqd London | N.Y.C | Paris | Hamburg | Berlin

    100% Agreed. Sadly this one hasn't popped up in my issue dashboard back in the days. Does anyone knows if it still persist?

    Apart from that: I'll close this issue ether way due to inactivity for 12 years and upcoming EOL of Drupal 7 in January 2025 β†’ . While the project version for Drupal 7 will keep providing support for security issues and website breaking bug fixes for Drupal 7, we should try to minimize the open issues for Drupal 7 in the queue as much as possible. Thanks for the report and all the efforts in here. Feel free to re-open if you can provide a fix or found an additional related problem which increases the issue priority to "Critical" here.

Production build 0.71.5 2024